mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dtc: dt-check-style: Check for closing bracket also on continued lines
@ 2026-11-13 18:34 Krzysztof Kozlowski
  2026-11-18 13:59 ` Rob Herring
  0 siblings, 1 reply; 2+ messages in thread
From: Krzysztof Kozlowski @ 2026-11-13 18:34 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Saravana Kannan,
	devicetree, linux-kernel
  Cc: Krzysztof Kozlowski

Fix incomplete check for closing brackets also for continued lines to
flag code like:
        reg = <0x100 0x10>,
              <0x200 0x10>; }

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
 scripts/dtc/dt-check-style                    | 19 +++++++++++--------
 .../bad/yaml-multi-close.yaml                 | 13 +++++++++++++
 .../expected/yaml-multi-close.yaml.txt        |  1 +
 3 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style
index 6bbd12b308a1..65d76f506518 100755
--- a/scripts/dtc/dt-check-style
+++ b/scripts/dtc/dt-check-style
@@ -675,20 +675,23 @@ def check_node_close_alone(ctx):
     that is all closures (e.g. "}; };") is still NODE_CLOSE for depth
     tracking but is flagged here via dl.closures. Any other line that
     still contains '};' (in code, not in strings or comments) is
-    mixing a node close with something else."""
+    mixing a node close with something else. Continuation lines of
+    multi-line properties are not part of ctx.lines, so check them
+    as well."""
     for dl in ctx.lines:
         if dl.linetype == LineType.NODE_CLOSE:
             if dl.closures > 1:
                 yield (dl.lineno,
                        'closing brace must be on its own line')
             continue
-        if dl.linetype in (LineType.BLANK, LineType.COMMENT,
-                           LineType.COMMENT_START, LineType.COMMENT_BODY,
-                           LineType.COMMENT_END, LineType.PREPROCESSOR):
-            continue
-        if '};' in dl.code:
-            yield (dl.lineno,
-                   'closing brace must be on its own line')
+        for d in [dl] + dl.continuations:
+            if d.linetype in (LineType.BLANK, LineType.COMMENT,
+                              LineType.COMMENT_START, LineType.COMMENT_BODY,
+                              LineType.COMMENT_END, LineType.PREPROCESSOR):
+                continue
+            if '};' in d.code:
+                yield (d.lineno,
+                       'closing brace must be on its own line')
 
 
 def check_node_name(ctx):
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-multi-close.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-multi-close.yaml
index afc202a698eb..80cf44340e4e 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-multi-close.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-multi-close.yaml
@@ -33,3 +33,16 @@ examples:
             compatible = "example,test-multi-close";
             reg = <0x100 0x10>;
         }; };
+
+  - |
+    bus@20000 {
+        compatible = "simple-bus";
+        reg = <0x20000 0x1000>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        device@100 {
+            compatible = "example,test-multi-close";
+            reg = <0x100 0x10>,
+                  <0x200 0x10>; };
+    };
diff --git a/scripts/dtc/dt-style-selftest/expected/yaml-multi-close.yaml.txt b/scripts/dtc/dt-style-selftest/expected/yaml-multi-close.yaml.txt
index 637d0f8ea103..ea38befa1bc3 100644
--- a/scripts/dtc/dt-style-selftest/expected/yaml-multi-close.yaml.txt
+++ b/scripts/dtc/dt-style-selftest/expected/yaml-multi-close.yaml.txt
@@ -1,3 +1,4 @@
 # mode=strict
 bad/yaml-multi-close.yaml:35: example 0 [indent-consistent] indent mismatch (expected depth 0 * '    ')
 bad/yaml-multi-close.yaml:35: example 0 [node-close-alone] closing brace must be on its own line
+bad/yaml-multi-close.yaml:47: example 1 [node-close-alone] closing brace must be on its own line
-- 
2.53.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-18 13:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-13 18:34 [PATCH] dtc: dt-check-style: Check for closing bracket also on continued lines Krzysztof Kozlowski
2026-11-18 13:59 ` Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®