[PATCH v2 2/6] dtc: dt-check-style: Handle continued lines in check_line_length()

From: Krzysztof Kozlowski

Date: Wed Sep 09 2026 - 04:43:01 EST


Continued lines are not separate DtsLine items in ctx.lines, so they
need own iteration. Rule for length of line is applicable to continued
values as well.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxxxxxxxx>
---
scripts/dtc/dt-check-style | 18 ++++++++++++------
scripts/dtc/dt-style-selftest/bad/dts-line-length.dts | 3 ++-
.../dtc/dt-style-selftest/bad/yaml-line-length.yaml | 3 ++-
.../dt-style-selftest/expected/dts-line-length.dts.txt | 1 +
.../expected/yaml-line-length.yaml.txt | 1 +
5 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style
index 6d978c4d9832..ff5e715593df 100755
--- a/scripts/dtc/dt-check-style
+++ b/scripts/dtc/dt-check-style
@@ -627,16 +627,22 @@ def check_indent_unit_strict(ctx):
'got %r' % unit)


+def _check_line_length(dl):
+ if dl.linetype == LineType.BLANK:
+ return
+ cols = _display_col(dl.raw)
+ if cols > 80:
+ yield (dl.lineno,
+ 'line exceeds 80 columns (%d)' % cols)
+
+
def check_line_length(ctx):
"""Lines must not exceed 80 columns; tabs count as 8 (see
_display_col)."""
for dl in ctx.lines:
- if dl.linetype == LineType.BLANK:
- continue
- cols = _display_col(dl.raw)
- if cols > 80:
- yield (dl.lineno,
- 'line exceeds 80 columns (%d)' % cols)
+ yield from _check_line_length(dl)
+ for cont in dl.continuations:
+ yield from _check_line_length(cont)


def check_mixed_indent_chars(ctx):
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-line-length.dts b/scripts/dtc/dt-style-selftest/bad/dts-line-length.dts
index bde91a922477..adf40e3c95f7 100644
--- a/scripts/dtc/dt-style-selftest/bad/dts-line-length.dts
+++ b/scripts/dtc/dt-style-selftest/bad/dts-line-length.dts
@@ -14,7 +14,8 @@ soc@0 {
#size-cells = <1>;

foo@1000 {
- compatible = "example,test-line-length-this-is-a-very-long-name-indeed-yeah";
+ compatible = "example,test-line-length-this-is-a-very-long-name-indeed-yeah",
+ "example,test-line-length-this-is-a-very-long-name-indeed-yeah-second";
reg = <0x1000 0x100>;
};
};
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-line-length.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-line-length.yaml
index 6e4140e500b5..6b1209ee4f26 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-line-length.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-line-length.yaml
@@ -24,6 +24,7 @@ additionalProperties: false
examples:
- |
foo@1000 {
- compatible = "example,test-line-length-this-is-a-very-long-name-indeed-yeah";
+ compatible = "example,test-line-length-this-is-a-very-long-name-indeed-yeah",
+ "example,test-line-length-this-is-a-very-long-name-indeed-yeah-second";
reg = <0x1000 0x100>;
};
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-line-length.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-line-length.dts.txt
index 8ed08c309632..9cdb7550b56c 100644
--- a/scripts/dtc/dt-style-selftest/expected/dts-line-length.dts.txt
+++ b/scripts/dtc/dt-style-selftest/expected/dts-line-length.dts.txt
@@ -1,2 +1,3 @@
# mode=stricter
bad/dts-line-length.dts:17: [line-length-dts] line exceeds 80 columns (101)
+bad/dts-line-length.dts:18: [line-length-dts] line exceeds 80 columns (108)
diff --git a/scripts/dtc/dt-style-selftest/expected/yaml-line-length.yaml.txt b/scripts/dtc/dt-style-selftest/expected/yaml-line-length.yaml.txt
index 89b36360caa4..f21b823c6136 100644
--- a/scripts/dtc/dt-style-selftest/expected/yaml-line-length.yaml.txt
+++ b/scripts/dtc/dt-style-selftest/expected/yaml-line-length.yaml.txt
@@ -1,2 +1,3 @@
# mode=strict
bad/yaml-line-length.yaml:27: example 0 [line-length] line exceeds 80 columns (81)
+bad/yaml-line-length.yaml:28: example 0 [line-length] line exceeds 80 columns (88)

--
2.53.0