[PATCH] dtc: dt-check-style: Check for closing bracket also on continued lines
From: Krzysztof Kozlowski
Date: Fri Nov 13 2026 - 16:23:39 EST
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@xxxxxxxxxxxxxxxx>
---
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