[PATCH v2 3/6] dtc: dt-check-style: Handle continued lines in check_trailing_whitespace()
From: Krzysztof Kozlowski
Date: Wed Sep 09 2026 - 04:43:26 EST
Continued lines are not separate DtsLine items in ctx.lines, so they
need own iteration. Rule for trailing white-space is applicable to
continued values as well.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxxxxxxxx>
---
scripts/dtc/dt-check-style | 10 ++++++++--
scripts/dtc/dt-style-selftest/bad/dts-trailing-ws.dts | 8 ++++++++
scripts/dtc/dt-style-selftest/bad/yaml-trailing-ws.yaml | 5 ++++-
scripts/dtc/dt-style-selftest/expected/dts-trailing-ws.dts.txt | 1 +
.../dtc/dt-style-selftest/expected/yaml-trailing-ws.yaml.txt | 2 ++
5 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style
index ff5e715593df..3694b0b1ebb6 100755
--- a/scripts/dtc/dt-check-style
+++ b/scripts/dtc/dt-check-style
@@ -985,10 +985,16 @@ def check_tab_in_yaml_example(ctx):
yield (cont.lineno, 'tab character not allowed in DTS example')
+def _check_trailing_whitespace(dl):
+ if dl.raw != dl.raw.rstrip():
+ yield (dl.lineno, 'trailing whitespace')
+
+
def check_trailing_whitespace(ctx):
for dl in ctx.lines:
- if dl.raw != dl.raw.rstrip():
- yield (dl.lineno, 'trailing whitespace')
+ yield from _check_trailing_whitespace(dl)
+ for cont in dl.continuations:
+ yield from _check_trailing_whitespace(cont)
def check_unclosed_block_comment(ctx):
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-trailing-ws.dts b/scripts/dtc/dt-style-selftest/bad/dts-trailing-ws.dts
index 1eb24d91c640..73c24525ce18 100644
--- a/scripts/dtc/dt-style-selftest/bad/dts-trailing-ws.dts
+++ b/scripts/dtc/dt-style-selftest/bad/dts-trailing-ws.dts
@@ -5,4 +5,12 @@ / {
compatible = "example,test-board";
#address-cells = <1>;
#size-cells = <1>;
+
+ interrupt-controller@10000 {
+ compatible = "example,intc";
+ reg = <0x10000 0x1000>;
+ clocks = <1 2 3>,
+ <4 5 6>,
+ <7 8 9>;
+ };
};
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-trailing-ws.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-trailing-ws.yaml
index f338c14174e6..17eeed3411c6 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-trailing-ws.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-trailing-ws.yaml
@@ -25,5 +25,8 @@ examples:
- |
device@1000 {
compatible = "example,test-trailing";
- reg = <0x1000 0x100>;
+ reg = <0x1000 0x100>,
+ <0x2000 0x100>,
+ <0x3000
+ 0x100>;
};
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-trailing-ws.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-trailing-ws.dts.txt
index 94d9ae9d616c..a15a7d637c30 100644
--- a/scripts/dtc/dt-style-selftest/expected/dts-trailing-ws.dts.txt
+++ b/scripts/dtc/dt-style-selftest/expected/dts-trailing-ws.dts.txt
@@ -1,2 +1,3 @@
# mode=relaxed
bad/dts-trailing-ws.dts:5: [trailing-whitespace] trailing whitespace
+bad/dts-trailing-ws.dts:13: [trailing-whitespace] trailing whitespace
diff --git a/scripts/dtc/dt-style-selftest/expected/yaml-trailing-ws.yaml.txt b/scripts/dtc/dt-style-selftest/expected/yaml-trailing-ws.yaml.txt
index cfdbc8476c73..4f2ec9572bc6 100644
--- a/scripts/dtc/dt-style-selftest/expected/yaml-trailing-ws.yaml.txt
+++ b/scripts/dtc/dt-style-selftest/expected/yaml-trailing-ws.yaml.txt
@@ -1,2 +1,4 @@
# mode=relaxed
bad/yaml-trailing-ws.yaml:27: example 0 [trailing-whitespace] trailing whitespace
+bad/yaml-trailing-ws.yaml:29: example 0 [trailing-whitespace] trailing whitespace
+bad/yaml-trailing-ws.yaml:30: example 0 [trailing-whitespace] trailing whitespace
--
2.53.0