* [PATCH v4 01/10] dtc: dt-check-style: Handle sorting of top-level nodes and properties
2026-08-26 7:05 [PATCH v4 00/10] dtc: dt-check-style: Improvements for false positives Krzysztof Kozlowski
@ 2026-08-26 7:05 ` Krzysztof Kozlowski
2026-08-26 7:05 ` [PATCH v4 02/10] dtc: dt-check-style: Drop stray backslash before quote for continuation-alignment Krzysztof Kozlowski
` (8 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Krzysztof Kozlowski @ 2026-08-26 7:05 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Krzysztof Kozlowski, Conor Dooley
Cc: devicetree, linux-kernel, Krzysztof Kozlowski
Top-level DTS (but not example in the bindings) has only two nodes with
unit-addresses: memory@ and soc@. There are two special cases here, in
terms of coding style:
1. The unit-address of memory is often not known thus set to @0, because
it is filled up by bootloader.
2. There is mixture of non-unit-address and unit-address nodes.
Therefore usually the DTS chooses for the top-level part sorting by the
node name, not the unit address.
Also the properties have one exception: 'model' property is supposed to
be before the 'compatible'. This cannot be applied to the entire DTS,
because sound cards have also 'model' where it is supposed to follow
standard rules (after the 'compatible'). Root node is just special.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
scripts/dtc/dt-check-style | 70 ++++++++++++++++++----
.../bad/dts-child-name-order.dtso | 33 ++++++++++
.../dt-style-selftest/bad/dts-digit-node-order.dts | 40 +++++++++++++
.../bad/dts-digit-node-order.dtso | 41 +++++++++++++
.../bad/dts-extend-node-child-name-order.dtso | 26 ++++++++
.../bad/dts-extend-node-digit-node-order.dtso | 34 +++++++++++
.../dt-style-selftest/bad/dts-property-order.dts | 7 ++-
.../dt-style-selftest/bad/dts-property-order.dtso | 49 +++++++++++++++
.../expected/dts-child-name-order.dts.txt | 1 +
.../expected/dts-child-name-order.dtso.txt | 3 +
.../expected/dts-digit-node-order.dts.txt | 2 +
.../expected/dts-digit-node-order.dtso.txt | 2 +
.../dts-extend-node-child-name-order.dtso.txt | 2 +
.../dts-extend-node-digit-node-order.dtso.txt | 2 +
.../expected/dts-property-order.dts.txt | 12 ++--
.../expected/dts-property-order.dtso.txt | 8 +++
.../good/dts-child-name-order.dtso | 44 ++++++++++++++
.../good/dts-digit-node-order.dts | 3 -
.../good/dts-digit-node-order.dtso | 59 ++++++++++++++++++
.../good/dts-extend-node-child-name-order.dtso | 26 ++++++++
.../good/dts-extend-node-digit-node-order.dtso | 34 +++++++++++
.../dt-style-selftest/good/dts-property-order.dts | 5 ++
.../dt-style-selftest/good/dts-property-order.dtso | 47 +++++++++++++++
23 files changed, 531 insertions(+), 19 deletions(-)
diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style
index 96deffc0d8a7..e5f26d3e2792 100755
--- a/scripts/dtc/dt-check-style
+++ b/scripts/dtc/dt-check-style
@@ -77,24 +77,26 @@ def is_preprocessor(stripped):
class DtsLine:
- __slots__ = ('lineno', 'raw', 'linetype', 'indent_str', 'stripped',
+ __slots__ = ('lineno', 'raw', 'linetype', 'indent_str', 'stripped', 'is_root',
'prop_name', 'continuations',
- 'node_name', 'node_addr', 'label', 'ref_name', 'depth',
+ 'node_name', 'node_addr', 'label', 'ref_name', 'parent', 'depth',
'closures')
- def __init__(self, lineno, raw, linetype, depth, indent_str, stripped):
+ def __init__(self, lineno, raw, linetype, depth, indent_str, stripped, is_root = False):
self.lineno = lineno # 1-based within the block
self.raw = raw
self.linetype = linetype
self.indent_str = indent_str # leading whitespace as-is
self.depth = depth
self.stripped = stripped
+ self.is_root = is_root
self.prop_name = None
self.continuations = []
self.node_name = None
self.node_addr = None
self.label = None
self.ref_name = None
+ self.parent = None # DtsLine of parent node
self.closures = 1 # count of '}' on a NODE_CLOSE line
@@ -228,7 +230,10 @@ def classify_lines(text):
continue
if code.endswith('{'):
- dl = DtsLine(i, raw, LineType.NODE_OPEN, depth, indent_str, code)
+ is_root = False
+ if code == '&{/} {' or re.search(r'^/\s*\{$', code):
+ is_root = True
+ dl = DtsLine(i, raw, LineType.NODE_OPEN, depth, indent_str, code, is_root=is_root)
parse_node_header(dl)
out.append(dl)
depth += 1
@@ -491,16 +496,24 @@ def _walk_bodies(lines):
"""Yield lists of immediate-child NODE_OPEN lines for each node body
in the input. Skips ref-nodes (&label) since those don't have an
intrinsic ordering."""
+ # Array of stacked nodes (parent/child)
body_stack = [[]]
+ # Current stack of nodes, purely to track parent relationship for each node
+ node_stack = []
+ parent_dl = None
for dl in lines:
if dl.linetype == LineType.NODE_OPEN:
+ dl.parent = parent_dl
+ node_stack.append(dl)
body_stack[-1].append(dl)
body_stack.append([])
+ parent_dl = dl
continue
if dl.linetype == LineType.NODE_CLOSE:
if len(body_stack) <= 1:
# Unbalanced; ignore to avoid crashing on malformed input
continue
+ parent_dl = node_stack.pop().parent
yield body_stack.pop()
continue
while body_stack:
@@ -521,12 +534,18 @@ def _natural_sort_key(s):
def check_child_address_order(ctx):
"""Addressed siblings (foo@N) must appear in ascending address
- order within their parent node body."""
+ order within their parent node body.
+ Exception: Top-level in DTS follows name order, regardless of unit address
+ in memory@N and soc@N nodes
+ """
for children in _walk_bodies(ctx.lines):
addressed = []
for c in children:
if c.node_addr is None:
continue
+ if c.parent and c.parent.is_root:
+ # Top-level does not use unit address sorting usually
+ continue
try:
parts = tuple(int(p, 16) for p in c.node_addr.split(','))
except ValueError:
@@ -544,12 +563,16 @@ def check_child_name_order(ctx):
"""Unaddressed siblings must appear in natural-sort order by node
name within their parent node body. Addressed children are scoped
by check_child_address_order; reference nodes (&label { ... }) and
- the root node are skipped."""
+ the root node are skipped.
+ However root node has children with and without unit address, and
+ sorting should be only by name."""
for children in _walk_bodies(ctx.lines):
unaddressed = []
for c in children:
if c.node_addr is not None:
- continue
+ # Skip nodes with unit address, except when sorting top-level
+ if not c.parent or not c.parent.is_root:
+ continue
if c.node_name in (None, '/'):
continue
if c.ref_name is not None:
@@ -591,6 +614,30 @@ def _property_bucket(name):
return (5 if ',' in stripped else 4, None)
+def _property_bucket_root(name):
+ """Return the canonical bucket index for a property:
+ 0 model (for root nodes only)
+ 1 compatible
+ Plus a sub-key inside the bucket for fixed slots (device_type, compatible,
+ reg, reg-names, ranges, status). 'standard' and 'vendor' return None for
+ the sub-key, signalling that the within-bucket key is computed by
+ the pairing rules."""
+ stripped = name.lstrip('#')
+ if name == 'model':
+ return (0, 0)
+ if name == 'compatible':
+ return (1, 0)
+ if name == 'reg':
+ return (2, 0)
+ if name == 'reg-names':
+ return (2, 1)
+ if name == 'ranges':
+ return (3, 0)
+ if name == 'status':
+ return (6, 0)
+ return (5 if ',' in stripped else 4, None)
+
+
# Declarative pairing rules: each is a callable
# (name, all_names) -> anchor_name_or_None
# If a rule returns an anchor, the property sorts immediately after the
@@ -627,13 +674,16 @@ def _pair_x_names(name, all_names):
PAIRING_RULES = (_pair_pinctrl_names, _pair_x_names)
-def _property_sort_key(name, all_names):
+def _property_sort_key(dl, name, all_names):
"""Sort key for a property among its node-body siblings.
Format: (bucket, within_key, tiebreak). 'within_key' for
standard/vendor buckets follows pairing rules: a property paired
with anchor X sorts as if it were X with a higher tiebreak."""
- bucket, fixed_sub = _property_bucket(name)
+ if dl.is_root:
+ bucket, fixed_sub = _property_bucket_root(name)
+ else:
+ bucket, fixed_sub = _property_bucket(name)
if fixed_sub is not None:
return (bucket, (), fixed_sub)
@@ -668,7 +718,7 @@ def check_property_order(ctx):
if len(props) < 2:
continue
all_names = [p.prop_name for p in props]
- keyed = [(p, _property_sort_key(p.prop_name, all_names))
+ keyed = [(p, _property_sort_key(dl, p.prop_name, all_names))
for p in props]
for k in range(1, len(keyed)):
if keyed[k][1] < keyed[k - 1][1]:
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-child-name-order.dtso b/scripts/dtc/dt-style-selftest/bad/dts-child-name-order.dtso
new file mode 100644
index 000000000000..74b49be69e98
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/dts-child-name-order.dtso
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+/plugin/;
+
+&{/} {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ pmu {
+ compatible = "example,pmu";
+
+ /* Include labels to be sure they do not affect sorting */
+ foo: foo {
+ label = "foo";
+ };
+
+ label_bar: bar {
+ label = "bar";
+ };
+ };
+
+ memory@a0000000 {
+ device_type = "memory";
+ reg = <0x0 0xa0000000 0x0 0x0>;
+ };
+
+ pmu-2 {
+ compatible = "example,pmu";
+
+ /* Just reference labels to avoid strict warnings */
+ example,foo = <&foo>, <&label_bar>;
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-digit-node-order.dts b/scripts/dtc/dt-style-selftest/bad/dts-digit-node-order.dts
new file mode 100644
index 000000000000..74c956398324
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/dts-digit-node-order.dts
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ memory@a0000000 {
+ device_type = "memory";
+ reg = <0x0 0xa0000000 0x0 0x0>;
+ };
+
+ pmu {
+ compatible = "example,pmu";
+ };
+
+ soc@0 {
+ compatible = "simple-bus";
+ ranges = <0 0 0 0xc0000000>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ serial@20000 {
+ compatible = "example,serial";
+ reg = <0x20000 0x1000>;
+ };
+
+ interrupt-controller@10000 {
+ compatible = "example,intc";
+ reg = <0x10000 0x1000>;
+ interrupts = <1 2 3>;
+ };
+
+ serial@30000 {
+ compatible = "example,serial";
+ reg = <0x30000 0x1000>;
+ };
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-digit-node-order.dtso b/scripts/dtc/dt-style-selftest/bad/dts-digit-node-order.dtso
new file mode 100644
index 000000000000..052c02935a45
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/dts-digit-node-order.dtso
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+/plugin/;
+
+&{/} {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ memory@a0000000 {
+ device_type = "memory";
+ reg = <0x0 0xa0000000 0x0 0x0>;
+ };
+
+ pmu {
+ compatible = "example,pmu";
+ };
+
+ soc@0 {
+ compatible = "simple-bus";
+ ranges = <0 0 0 0xc0000000>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ serial@20000 {
+ compatible = "example,serial";
+ reg = <0x20000 0x1000>;
+ };
+
+ interrupt-controller@10000 {
+ compatible = "example,intc";
+ reg = <0x10000 0x1000>;
+ interrupts = <1 2 3>;
+ };
+
+ serial@30000 {
+ compatible = "example,serial";
+ reg = <0x30000 0x1000>;
+ };
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-extend-node-child-name-order.dtso b/scripts/dtc/dt-style-selftest/bad/dts-extend-node-child-name-order.dtso
new file mode 100644
index 000000000000..d9cf670f19f6
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/dts-extend-node-child-name-order.dtso
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+/plugin/;
+
+&{/} {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ pmu {
+ compatible = "example,pmu";
+
+ /* Just reference labels to avoid strict warnings */
+ example,foo = <&foo>, <&label_bar>;
+ };
+};
+
+&pmu {
+ /* Include labels to be sure they do not affect sorting */
+ foo: foo {
+ label = "foo";
+ };
+
+ label_bar: bar {
+ label = "bar";
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-extend-node-digit-node-order.dtso b/scripts/dtc/dt-style-selftest/bad/dts-extend-node-digit-node-order.dtso
new file mode 100644
index 000000000000..4b2cf60e5a92
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/dts-extend-node-digit-node-order.dtso
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+/plugin/;
+
+&{/} {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ soc: soc@0 {
+ compatible = "simple-bus";
+ ranges = <0 0 0 0xc0000000>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+ };
+};
+
+&soc {
+ serial@20000 {
+ compatible = "example,serial";
+ reg = <0x20000 0x1000>;
+ };
+
+ interrupt-controller@10000 {
+ compatible = "example,intc";
+ reg = <0x10000 0x1000>;
+ interrupts = <1 2 3>;
+ };
+
+ serial@30000 {
+ compatible = "example,serial";
+ reg = <0x30000 0x1000>;
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-property-order.dts b/scripts/dtc/dt-style-selftest/bad/dts-property-order.dts
index f31abb6ceae4..e675e5e05a46 100644
--- a/scripts/dtc/dt-style-selftest/bad/dts-property-order.dts
+++ b/scripts/dtc/dt-style-selftest/bad/dts-property-order.dts
@@ -5,7 +5,12 @@
/dts-v1/;
-/ {
+/ {
+ compatible = "example,test-board", "example,test-soc";
+ model = "DT style selftest";
+ qcom,board-id = <8 0>;
+ chassis-type = "handset";
+
cpus {
#address-cells = <1>;
#size-cells = <0>;
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-property-order.dtso b/scripts/dtc/dt-style-selftest/bad/dts-property-order.dtso
new file mode 100644
index 000000000000..81ac2b092b96
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/dts-property-order.dtso
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/*
+ * Test fixture: Incorrect property order
+ */
+
+/dts-v1/;
+/plugin/;
+
+&{/} {
+ compatible = "example,test-board", "example,test-soc";
+ model = "DT style selftest";
+ qcom,board-id = <8 0>;
+ chassis-type = "handset";
+
+ cpus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ cpu@0 {
+ reg = <0x0 0x0>;
+ compatible = "arm,cortex-a57";
+ device_type = "cpu";
+ enable-method = "psci";
+ };
+ };
+
+ pmu {
+ compatible = "example,pmu";
+
+ status = "disabled";
+ dma-coherent;
+ };
+
+ soc@0 {
+ ranges = <0 0 0 0xc0000000>;
+ compatible = "simple-bus";
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ interrupt-controller@10000 {
+ reg = <0x10000 0x1000>;
+ interrupts = <1 2 3>,
+ <4 5 6>,
+ <7 8 9>;
+ compatible = "example,intc";
+ };
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-child-name-order.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-child-name-order.dts.txt
index e2eea0862102..312a45ed913a 100644
--- a/scripts/dtc/dt-style-selftest/expected/dts-child-name-order.dts.txt
+++ b/scripts/dtc/dt-style-selftest/expected/dts-child-name-order.dts.txt
@@ -1,2 +1,3 @@
# mode=strict
bad/dts-child-name-order.dts:16: [child-name-order] child node 'bar' out of name order
+bad/dts-child-name-order.dts:21: [child-name-order] child node 'memory' out of name order
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-child-name-order.dtso.txt b/scripts/dtc/dt-style-selftest/expected/dts-child-name-order.dtso.txt
new file mode 100644
index 000000000000..e44ceb24ece8
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/dts-child-name-order.dtso.txt
@@ -0,0 +1,3 @@
+# mode=strict
+bad/dts-child-name-order.dtso:17: [child-name-order] child node 'bar' out of name order
+bad/dts-child-name-order.dtso:22: [child-name-order] child node 'memory' out of name order
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-digit-node-order.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-digit-node-order.dts.txt
new file mode 100644
index 000000000000..1f41acdea0b0
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/dts-digit-node-order.dts.txt
@@ -0,0 +1,2 @@
+# mode=strict
+bad/dts-digit-node-order.dts:29: [child-address-order] child node @10000 out of address order
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-digit-node-order.dtso.txt b/scripts/dtc/dt-style-selftest/expected/dts-digit-node-order.dtso.txt
new file mode 100644
index 000000000000..21db32f6e639
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/dts-digit-node-order.dtso.txt
@@ -0,0 +1,2 @@
+# mode=strict
+bad/dts-digit-node-order.dtso:30: [child-address-order] child node @10000 out of address order
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-extend-node-child-name-order.dtso.txt b/scripts/dtc/dt-style-selftest/expected/dts-extend-node-child-name-order.dtso.txt
new file mode 100644
index 000000000000..d7941a891135
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/dts-extend-node-child-name-order.dtso.txt
@@ -0,0 +1,2 @@
+# mode=strict
+bad/dts-extend-node-child-name-order.dtso:23: [child-name-order] child node 'bar' out of name order
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-extend-node-digit-node-order.dtso.txt b/scripts/dtc/dt-style-selftest/expected/dts-extend-node-digit-node-order.dtso.txt
new file mode 100644
index 000000000000..408796d5bb03
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/dts-extend-node-digit-node-order.dtso.txt
@@ -0,0 +1,2 @@
+# mode=strict
+bad/dts-extend-node-digit-node-order.dtso:24: [child-address-order] child node @10000 out of address order
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-property-order.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-property-order.dts.txt
index 4bc21328625f..65977f96331d 100644
--- a/scripts/dtc/dt-style-selftest/expected/dts-property-order.dts.txt
+++ b/scripts/dtc/dt-style-selftest/expected/dts-property-order.dts.txt
@@ -1,6 +1,8 @@
# mode=strict
-bad/dts-property-order.dts:15: [property-order] property 'compatible' out of canonical order (should sort before 'reg')
-bad/dts-property-order.dts:16: [property-order] property 'device_type' out of canonical order (should sort before 'compatible')
-bad/dts-property-order.dts:25: [property-order] property 'dma-coherent' out of canonical order (should sort before 'status')
-bad/dts-property-order.dts:30: [property-order] property 'compatible' out of canonical order (should sort before 'ranges')
-bad/dts-property-order.dts:40: [property-order] property 'compatible' out of canonical order (should sort before 'interrupts')
+bad/dts-property-order.dts:10: [property-order] property 'model' out of canonical order (should sort before 'compatible')
+bad/dts-property-order.dts:12: [property-order] property 'chassis-type' out of canonical order (should sort before 'qcom,board-id')
+bad/dts-property-order.dts:20: [property-order] property 'compatible' out of canonical order (should sort before 'reg')
+bad/dts-property-order.dts:21: [property-order] property 'device_type' out of canonical order (should sort before 'compatible')
+bad/dts-property-order.dts:30: [property-order] property 'dma-coherent' out of canonical order (should sort before 'status')
+bad/dts-property-order.dts:35: [property-order] property 'compatible' out of canonical order (should sort before 'ranges')
+bad/dts-property-order.dts:45: [property-order] property 'compatible' out of canonical order (should sort before 'interrupts')
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-property-order.dtso.txt b/scripts/dtc/dt-style-selftest/expected/dts-property-order.dtso.txt
new file mode 100644
index 000000000000..124183fab2ad
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/dts-property-order.dtso.txt
@@ -0,0 +1,8 @@
+# mode=strict
+bad/dts-property-order.dtso:11: [property-order] property 'model' out of canonical order (should sort before 'compatible')
+bad/dts-property-order.dtso:13: [property-order] property 'chassis-type' out of canonical order (should sort before 'qcom,board-id')
+bad/dts-property-order.dtso:21: [property-order] property 'compatible' out of canonical order (should sort before 'reg')
+bad/dts-property-order.dtso:22: [property-order] property 'device_type' out of canonical order (should sort before 'compatible')
+bad/dts-property-order.dtso:31: [property-order] property 'dma-coherent' out of canonical order (should sort before 'status')
+bad/dts-property-order.dtso:36: [property-order] property 'compatible' out of canonical order (should sort before 'ranges')
+bad/dts-property-order.dtso:46: [property-order] property 'compatible' out of canonical order (should sort before 'interrupts')
diff --git a/scripts/dtc/dt-style-selftest/good/dts-child-name-order.dtso b/scripts/dtc/dt-style-selftest/good/dts-child-name-order.dtso
new file mode 100644
index 000000000000..1fd75a6285ce
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/good/dts-child-name-order.dtso
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+/plugin/;
+
+&{/} {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ memory@a0000000 {
+ device_type = "memory";
+ reg = <0x0 0xa0000000 0x0 0x0>;
+ };
+
+ pmu {
+ compatible = "example,pmu";
+
+ /* Include labels to be sure they do not affect sorting */
+ label_bar: bar {
+ label = "bar";
+ };
+
+ foo: foo {
+ label = "foo";
+ };
+ };
+
+ pmu-2 {
+ compatible = "example,pmu";
+
+ /* Just reference labels to avoid strict warnings */
+ example,foo = <&foo>, <&label_bar>;
+ };
+};
+
+&pmu {
+ /* Include labels to be sure they do not affect sorting */
+ label_bar_2: bar-2 {
+ label = "bar";
+ };
+
+ foo_2: foo-2 {
+ label = "foo";
+ };
+}
diff --git a/scripts/dtc/dt-style-selftest/good/dts-digit-node-order.dts b/scripts/dtc/dt-style-selftest/good/dts-digit-node-order.dts
index cdf3f91ebe01..2b21dde7f3c8 100644
--- a/scripts/dtc/dt-style-selftest/good/dts-digit-node-order.dts
+++ b/scripts/dtc/dt-style-selftest/good/dts-digit-node-order.dts
@@ -5,13 +5,10 @@ / {
#address-cells = <1>;
#size-cells = <1>;
- /* TODO: uncomment when child-address-order is fixed for top-level */
- /*
memory@a0000000 {
device_type = "memory";
reg = <0x0 0xa0000000 0x0 0x0>;
};
- */
pmu {
compatible = "example,pmu";
diff --git a/scripts/dtc/dt-style-selftest/good/dts-digit-node-order.dtso b/scripts/dtc/dt-style-selftest/good/dts-digit-node-order.dtso
new file mode 100644
index 000000000000..efafa1cccc15
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/good/dts-digit-node-order.dtso
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+/plugin/;
+
+&{/} {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ memory@a0000000 {
+ device_type = "memory";
+ reg = <0x0 0xa0000000 0x0 0x0>;
+ };
+
+ pmu {
+ compatible = "example,pmu";
+ };
+
+ soc@0 {
+ compatible = "simple-bus";
+ ranges = <0 0 0 0xc0000000>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ interrupt-controller@10000 {
+ compatible = "example,intc";
+ reg = <0x10000 0x1000>;
+ interrupts = <1 2 3>;
+ };
+
+ serial@20000 {
+ compatible = "example,serial";
+ reg = <0x20000 0x1000>;
+ };
+
+ serial@30000 {
+ compatible = "example,serial";
+ reg = <0x30000 0x1000>;
+ };
+ };
+};
+
+&soc {
+ interrupt-controller@110000 {
+ compatible = "example,intc";
+ reg = <0x110000 0x1000>;
+ interrupts = <1 2 3>;
+ };
+
+ serial@120000 {
+ compatible = "example,serial";
+ reg = <0x120000 0x1000>;
+ };
+
+ serial@130000 {
+ compatible = "example,serial";
+ reg = <0x130000 0x1000>;
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/good/dts-extend-node-child-name-order.dtso b/scripts/dtc/dt-style-selftest/good/dts-extend-node-child-name-order.dtso
new file mode 100644
index 000000000000..b00c2a195179
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/good/dts-extend-node-child-name-order.dtso
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+/plugin/;
+
+&{/} {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ pmu {
+ compatible = "example,pmu";
+
+ /* Just reference labels to avoid strict warnings */
+ example,foo = <&foo>, <&label_bar>;
+ };
+};
+
+&pmu {
+ /* Include labels to be sure they do not affect sorting */
+ label_bar: bar {
+ label = "bar";
+ };
+
+ foo: foo {
+ label = "foo";
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/good/dts-extend-node-digit-node-order.dtso b/scripts/dtc/dt-style-selftest/good/dts-extend-node-digit-node-order.dtso
new file mode 100644
index 000000000000..1ce18afb80de
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/good/dts-extend-node-digit-node-order.dtso
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+/plugin/;
+
+&{/} {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ soc: soc@0 {
+ compatible = "simple-bus";
+ ranges = <0 0 0 0xc0000000>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+ };
+};
+
+&soc {
+ interrupt-controller@10000 {
+ compatible = "example,intc";
+ reg = <0x10000 0x1000>;
+ interrupts = <1 2 3>;
+ };
+
+ serial@20000 {
+ compatible = "example,serial";
+ reg = <0x20000 0x1000>;
+ };
+
+ serial@30000 {
+ compatible = "example,serial";
+ reg = <0x30000 0x1000>;
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/good/dts-property-order.dts b/scripts/dtc/dt-style-selftest/good/dts-property-order.dts
index 0e183e3459cd..3d847cc9fa3e 100644
--- a/scripts/dtc/dt-style-selftest/good/dts-property-order.dts
+++ b/scripts/dtc/dt-style-selftest/good/dts-property-order.dts
@@ -6,6 +6,11 @@
/dts-v1/;
/ {
+ model = "DT style selftest";
+ compatible = "example,test-board", "example,test-soc";
+ chassis-type = "handset";
+ qcom,board-id = <8 0>;
+
cpus {
#address-cells = <1>;
#size-cells = <0>;
diff --git a/scripts/dtc/dt-style-selftest/good/dts-property-order.dtso b/scripts/dtc/dt-style-selftest/good/dts-property-order.dtso
new file mode 100644
index 000000000000..5ae78541f68b
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/good/dts-property-order.dtso
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/*
+ * Test fixture: Incorrect property order
+ */
+
+/dts-v1/;
+/plugin/;
+
+&{/} {
+ model = "DT style selftest";
+ compatible = "example,test-board", "example,test-soc";
+ chassis-type = "handset";
+ qcom,board-id = <8 0>;
+
+ cpus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ cpu@0 {
+ device_type = "cpu";
+ compatible = "arm,cortex-a57";
+ reg = <0x0 0x0>;
+ enable-method = "psci";
+ };
+ };
+
+ pmu {
+ compatible = "example,pmu";
+ dma-coherent;
+
+ status = "disabled";
+ };
+
+ soc@0 {
+ compatible = "simple-bus";
+ ranges = <0 0 0 0xc0000000>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ interrupt-controller@10000 {
+ compatible = "example,intc";
+ reg = <0x10000 0x1000>;
+ interrupts = <1 2 3>;
+ };
+ };
+};
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v4 02/10] dtc: dt-check-style: Drop stray backslash before quote for continuation-alignment
2026-08-26 7:05 [PATCH v4 00/10] dtc: dt-check-style: Improvements for false positives Krzysztof Kozlowski
2026-08-26 7:05 ` [PATCH v4 01/10] dtc: dt-check-style: Handle sorting of top-level nodes and properties Krzysztof Kozlowski
@ 2026-08-26 7:05 ` Krzysztof Kozlowski
2026-08-26 7:05 ` [PATCH v4 03/10] dtc: dt-check-style: Fix alignment of values in continued property lines Krzysztof Kozlowski
` (7 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Krzysztof Kozlowski @ 2026-08-26 7:05 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Krzysztof Kozlowski, Conor Dooley
Cc: devicetree, linux-kernel, Krzysztof Kozlowski
Drop stray backslash before the quote character in a warning for
continuation-alignment rule: (under "<" or \"). Since the '"' character
has no quotes, drop the quotes also from '<'.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
scripts/dtc/dt-check-style | 4 ++--
scripts/dtc/dt-style-selftest/expected/yaml-cont-align.yaml.txt | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style
index e5f26d3e2792..833f8a03ddc9 100755
--- a/scripts/dtc/dt-check-style
+++ b/scripts/dtc/dt-check-style
@@ -948,7 +948,7 @@ def check_continuation_alignment(ctx):
if _display_col(cont.indent_str) != target_col:
yield (cont.lineno,
'continuation should align to column %d '
- '(under "<" or \\")' % (target_col + 1))
+ '(under < or ")' % (target_col + 1))
def check_unclosed_block_comment(ctx):
@@ -1052,7 +1052,7 @@ RULES = [
'lines must not exceed 80 columns',
check_line_length),
Rule('continuation-alignment', 'strict',
- 'multi-line property continuations align under "<" or "\\""',
+ 'multi-line property continuations align under < or "',
check_continuation_alignment),
Rule('unused-labels', 'strict',
'every label must be &-referenced in the same example/file '
diff --git a/scripts/dtc/dt-style-selftest/expected/yaml-cont-align.yaml.txt b/scripts/dtc/dt-style-selftest/expected/yaml-cont-align.yaml.txt
index b5576dd0f6b1..c0801c56d5db 100644
--- a/scripts/dtc/dt-style-selftest/expected/yaml-cont-align.yaml.txt
+++ b/scripts/dtc/dt-style-selftest/expected/yaml-cont-align.yaml.txt
@@ -1,2 +1,2 @@
# mode=strict
-bad/yaml-cont-align.yaml:29: example 0 [continuation-alignment] continuation should align to column 11 (under "<" or \")
+bad/yaml-cont-align.yaml:29: example 0 [continuation-alignment] continuation should align to column 11 (under < or ")
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v4 03/10] dtc: dt-check-style: Fix alignment of values in continued property lines
2026-08-26 7:05 [PATCH v4 00/10] dtc: dt-check-style: Improvements for false positives Krzysztof Kozlowski
2026-08-26 7:05 ` [PATCH v4 01/10] dtc: dt-check-style: Handle sorting of top-level nodes and properties Krzysztof Kozlowski
2026-08-26 7:05 ` [PATCH v4 02/10] dtc: dt-check-style: Drop stray backslash before quote for continuation-alignment Krzysztof Kozlowski
@ 2026-08-26 7:05 ` Krzysztof Kozlowski
2026-08-26 7:13 ` sashiko-bot
2026-08-26 7:05 ` [PATCH v4 04/10] dtc: dt-check-style: Consistently call 'kind' as 'file_type' Krzysztof Kozlowski
` (6 subsequent siblings)
9 siblings, 1 reply; 15+ messages in thread
From: Krzysztof Kozlowski @ 2026-08-26 7:05 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Krzysztof Kozlowski, Conor Dooley
Cc: devicetree, linux-kernel, Krzysztof Kozlowski
Continued lines in property assignments should be indented to opening
'<' or '"' if they also start with that character, e.g.:
reg = <0x1000 0x100>,
<0x2000 0x100>;
If the continued line is part of previous phandle, then alignment should
be to inner values to make it more readable, e.g.:
reg = <0x1000 0x100
0x2000 0x100>;
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
scripts/dtc/dt-check-style | 27 ++++++++++++------
.../dtc/dt-style-selftest/bad/dts-cont-align.dts | 23 ++++++++++++++++
.../dtc/dt-style-selftest/bad/yaml-cont-align.yaml | 4 ++-
.../expected/dts-cont-align.dts.txt | 8 ++++++
.../expected/yaml-cont-align.yaml.txt | 3 +-
.../expected/yaml-value-ws-multiline.yaml.txt | 1 +
.../dtc/dt-style-selftest/good/dts-cont-align.dts | 11 +++++---
.../dt-style-selftest/good/yaml-cont-align.yaml | 32 ++++++++++++++++++++++
8 files changed, 94 insertions(+), 15 deletions(-)
diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style
index 833f8a03ddc9..486dd1d6bb9a 100755
--- a/scripts/dtc/dt-check-style
+++ b/scripts/dtc/dt-check-style
@@ -926,10 +926,11 @@ def check_line_length(ctx):
def check_continuation_alignment(ctx):
"""A multi-line property's continuation lines must align their
- first non-whitespace character to the display column of the first
- '<' or '"' after the '=' in the leading line. Display columns are
- used so tab-indented .dts files (where a continuation aligns with
- tabs plus spaces) are compared correctly."""
+ first non-whitespace character to the display column of:
+ 1. the first '<' or '"' after the '=' in the leading line, if continuation is with '<' or '"'
+ 2. the first value, if the continuation is still the same phandle.
+ Display columns are used so tab-indented .dts files (where a continuation
+ aligns with tabs plus spaces) are compared correctly."""
for dl in ctx.lines:
if dl.linetype != LineType.PROPERTY:
continue
@@ -940,15 +941,23 @@ def check_continuation_alignment(ctx):
continue
# First '<' or '"' after '='
rest = dl.raw[eq + 1:]
- m = re.search(r'[<"]', rest)
+ m = re.search(r'\s*([<"])', rest)
if not m:
continue
- target_col = _display_col(dl.raw[:eq + 1 + m.start()])
+ dl_value_complete = rest.endswith('",') or rest.endswith('>,')
+ target_col = _display_col(dl.raw[:eq + 1 + m.start(1)])
for cont in dl.continuations:
- if _display_col(cont.indent_str) != target_col:
+ target_offset = 0
+ err_msg_explanation = 'to < or "'
+ if not dl_value_complete:
+ target_offset = 1
+ err_msg_explanation = 'to the value under <'
+ if _display_col(cont.indent_str) != target_col + target_offset:
yield (cont.lineno,
'continuation should align to column %d '
- '(under < or ")' % (target_col + 1))
+ '(%s)' % (target_col + target_offset + 1, err_msg_explanation))
+ # Align to the value within <> or "" of continuation (so the previous line)
+ dl_value_complete = cont.stripped.endswith('",') or cont.stripped.endswith('>,')
def check_unclosed_block_comment(ctx):
@@ -1052,7 +1061,7 @@ RULES = [
'lines must not exceed 80 columns',
check_line_length),
Rule('continuation-alignment', 'strict',
- 'multi-line property continuations align under < or "',
+ 'multi-line property continuations align under <, " or the value under <',
check_continuation_alignment),
Rule('unused-labels', 'strict',
'every label must be &-referenced in the same example/file '
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-cont-align.dts b/scripts/dtc/dt-style-selftest/bad/dts-cont-align.dts
new file mode 100644
index 000000000000..2087dac23d96
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/dts-cont-align.dts
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+
+/ {
+ compatible = "example,test-board";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ interrupt-controller@10000 {
+ compatible = "example,intc";
+ reg = <0x10000 0x1000>;
+ interrupts = <1 2 3>,
+ <4 5 6>,
+ <7 8 9>;
+ pinmux = <0x01
+ 0x02>,
+ <0x03
+ 0x04>;
+ power-domain-names = "foo",
+ "bar",
+ "baz";
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-cont-align.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-cont-align.yaml
index 92778540b056..d4662acc7b8f 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-cont-align.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-cont-align.yaml
@@ -26,5 +26,7 @@ examples:
foo@1000 {
compatible = "example,test-cont-align";
reg = <0x1000 0x100>,
- <0x2000 0x100>;
+ <0x2000 0x100>,
+ <0x3000
+ 0x100>;
};
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-cont-align.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-cont-align.dts.txt
new file mode 100644
index 000000000000..a4672206859c
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/dts-cont-align.dts.txt
@@ -0,0 +1,8 @@
+# mode=strict
+bad/dts-cont-align.dts:13: [continuation-alignment] continuation should align to column 30 (to < or ")
+bad/dts-cont-align.dts:14: [continuation-alignment] continuation should align to column 30 (to < or ")
+bad/dts-cont-align.dts:16: [continuation-alignment] continuation should align to column 27 (to the value under <)
+bad/dts-cont-align.dts:17: [continuation-alignment] continuation should align to column 26 (to < or ")
+bad/dts-cont-align.dts:18: [continuation-alignment] continuation should align to column 27 (to the value under <)
+bad/dts-cont-align.dts:20: [continuation-alignment] continuation should align to column 38 (to < or ")
+bad/dts-cont-align.dts:21: [continuation-alignment] continuation should align to column 38 (to < or ")
diff --git a/scripts/dtc/dt-style-selftest/expected/yaml-cont-align.yaml.txt b/scripts/dtc/dt-style-selftest/expected/yaml-cont-align.yaml.txt
index c0801c56d5db..eb9a84d5c222 100644
--- a/scripts/dtc/dt-style-selftest/expected/yaml-cont-align.yaml.txt
+++ b/scripts/dtc/dt-style-selftest/expected/yaml-cont-align.yaml.txt
@@ -1,2 +1,3 @@
# mode=strict
-bad/yaml-cont-align.yaml:29: example 0 [continuation-alignment] continuation should align to column 11 (under < or ")
+bad/yaml-cont-align.yaml:29: example 0 [continuation-alignment] continuation should align to column 11 (to < or ")
+bad/yaml-cont-align.yaml:31: example 0 [continuation-alignment] continuation should align to column 12 (to the value under <)
diff --git a/scripts/dtc/dt-style-selftest/expected/yaml-value-ws-multiline.yaml.txt b/scripts/dtc/dt-style-selftest/expected/yaml-value-ws-multiline.yaml.txt
index 3df55b1762d0..d25b5b425e3f 100644
--- a/scripts/dtc/dt-style-selftest/expected/yaml-value-ws-multiline.yaml.txt
+++ b/scripts/dtc/dt-style-selftest/expected/yaml-value-ws-multiline.yaml.txt
@@ -1,2 +1,3 @@
# mode=strict
bad/yaml-value-ws-multiline.yaml:25: example 0 [value-whitespace] extra whitespace inside <...>
+bad/yaml-value-ws-multiline.yaml:26: example 0 [continuation-alignment] continuation should align to column 12 (to the value under <)
diff --git a/scripts/dtc/dt-style-selftest/good/dts-cont-align.dts b/scripts/dtc/dt-style-selftest/good/dts-cont-align.dts
index 36fb4eefcd83..1a1c07c09a41 100644
--- a/scripts/dtc/dt-style-selftest/good/dts-cont-align.dts
+++ b/scripts/dtc/dt-style-selftest/good/dts-cont-align.dts
@@ -18,9 +18,12 @@ interrupt-controller@10000 {
interrupts = <1 2 3>,
<4 5 6>,
<7 8 9>;
- pinmux = <
- 0x01
- 0x02
- >;
+ pinmux = <0x01
+ 0x02>,
+ <0x03
+ 0x04>;
+ power-domain-names = "foo",
+ "bar",
+ "baz";
};
};
diff --git a/scripts/dtc/dt-style-selftest/good/yaml-cont-align.yaml b/scripts/dtc/dt-style-selftest/good/yaml-cont-align.yaml
new file mode 100644
index 000000000000..2e7b8582bb7c
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/good/yaml-cont-align.yaml
@@ -0,0 +1,32 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/test-good-cont-align.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Test fixture with aligned multi-line property
+
+maintainers:
+ - Test User <test@example.com>
+
+properties:
+ compatible:
+ const: example,test-cont-align
+ reg:
+ maxItems: 2
+
+required:
+ - compatible
+ - reg
+
+additionalProperties: false
+
+examples:
+ - |
+ foo@1000 {
+ compatible = "example,test-cont-align";
+ reg = <0x1000 0x100>,
+ <0x2000 0x100>,
+ <0x3000
+ 0x100>;
+ };
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH v4 03/10] dtc: dt-check-style: Fix alignment of values in continued property lines
2026-08-26 7:05 ` [PATCH v4 03/10] dtc: dt-check-style: Fix alignment of values in continued property lines Krzysztof Kozlowski
@ 2026-08-26 7:13 ` sashiko-bot
2026-08-26 10:00 ` Krzysztof Kozlowski
0 siblings, 1 reply; 15+ messages in thread
From: sashiko-bot @ 2026-08-26 7:13 UTC (permalink / raw)
To: Krzysztof Kozlowski; +Cc: conor+dt, robh, devicetree
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Trailing whitespace or comments break multi-line property alignment validation.
--
commit aff0e119d6465ed21424e22c5bbba8149c80bcf4
Author: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
dtc: dt-check-style: Fix alignment of values in continued property lines
This commit updates the device tree style checker to properly enforce
alignment rules for continued property lines. It adds logic to ensure inner
values inside phandles or strings are aligned correctly based on the
previous line's completion status.
> diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style
> index 833f8a03ddc9b..486dd1d6bb9a7 100755
> --- a/scripts/dtc/dt-check-style
> +++ b/scripts/dtc/dt-check-style
[ ... ]
> @@ -940,15 +941,23 @@ def check_continuation_alignment(ctx):
> continue
> # First '<' or '"' after '='
> rest = dl.raw[eq + 1:]
> - m = re.search(r'[<"]', rest)
> + m = re.search(r'\s*([<"])', rest)
> if not m:
> continue
> - target_col = _display_col(dl.raw[:eq + 1 + m.start()])
> + dl_value_complete = rest.endswith('",') or rest.endswith('>,')
[Severity: Low]
Does this evaluation properly handle trailing inline comments or whitespace?
If the rest string retains trailing characters like inline comments
(e.g. >, /* foo */) or unexpected whitespace, endswith() will return false
even if the value is complete. This could cause the script to incorrectly
conclude the property is incomplete and mandate an incorrect indentation
for the continuation line.
> + target_col = _display_col(dl.raw[:eq + 1 + m.start(1)])
> for cont in dl.continuations:
> - if _display_col(cont.indent_str) != target_col:
> + target_offset = 0
> + err_msg_explanation = 'to < or "'
> + if not dl_value_complete:
> + target_offset = 1
> + err_msg_explanation = 'to the value under <'
> + if _display_col(cont.indent_str) != target_col + target_offset:
> yield (cont.lineno,
> 'continuation should align to column %d '
> - '(under < or ")' % (target_col + 1))
> + '(%s)' % (target_col + target_offset + 1, err_msg_explanation))
> + # Align to the value within <> or "" of continuation (so the previous line)
> + dl_value_complete = cont.stripped.endswith('",') or cont.stripped.endswith('>,')
[Severity: Low]
Can this cause false positives for chained continuation lines?
Similarly to the rest variable above, if cont.stripped retains trailing
comments, endswith() will evaluate to false. Could this result in the same
false-positive warnings when checking the next continuation line?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260826-n-dts-style-checker-continued-v4-0-022e60091965@oss.qualcomm.com?part=3
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v4 03/10] dtc: dt-check-style: Fix alignment of values in continued property lines
2026-08-26 7:13 ` sashiko-bot
@ 2026-08-26 10:00 ` Krzysztof Kozlowski
0 siblings, 0 replies; 15+ messages in thread
From: Krzysztof Kozlowski @ 2026-08-26 10:00 UTC (permalink / raw)
To: sashiko-reviews; +Cc: conor+dt, robh, devicetree
On 26/08/2026 09:13, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Low] Trailing whitespace or comments break multi-line property alignment validation.
Ack
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v4 04/10] dtc: dt-check-style: Consistently call 'kind' as 'file_type'
2026-08-26 7:05 [PATCH v4 00/10] dtc: dt-check-style: Improvements for false positives Krzysztof Kozlowski
` (2 preceding siblings ...)
2026-08-26 7:05 ` [PATCH v4 03/10] dtc: dt-check-style: Fix alignment of values in continued property lines Krzysztof Kozlowski
@ 2026-08-26 7:05 ` Krzysztof Kozlowski
2026-08-26 7:05 ` [PATCH v4 05/10] dtc: dt-check-style: Introduce 'stricter' mode Krzysztof Kozlowski
` (5 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Krzysztof Kozlowski @ 2026-08-26 7:05 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Krzysztof Kozlowski, Conor Dooley
Cc: devicetree, linux-kernel, Krzysztof Kozlowski
Script was using different names for variables or attributes with the
same meaning: the type of file (YAML, DTS, DTSI, DTSO). Unify 'kind',
'input_kind' and function input_kind() to consistent 'file_type'.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
scripts/dtc/dt-check-style | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style
index 486dd1d6bb9a..a8a3b6e0f7db 100755
--- a/scripts/dtc/dt-check-style
+++ b/scripts/dtc/dt-check-style
@@ -314,13 +314,13 @@ def collect_labels_and_refs(text):
class Ctx:
"""Context passed to each rule check. Carries the parsed lines,
- raw text, mode and kind."""
+ raw text, mode and file_type."""
- def __init__(self, lines, text, mode, kind):
+ def __init__(self, lines, text, mode, file_type):
self.lines = lines
self.text = text
self.mode = mode # 'relaxed' or 'strict'
- if kind in DTS_FAMILY:
+ if file_type in DTS_FAMILY:
self.file_type = 'dts'
else:
self.file_type = 'yaml'
@@ -1070,14 +1070,14 @@ RULES = [
]
-def select_rules(mode, input_kind):
+def select_rules(mode, file_type):
"""Return rules that apply to the given mode and input type."""
rank = {'relaxed': 0, 'strict': 1}
out = []
for r in RULES:
if rank[r.mode] > rank[mode]:
continue
- if input_kind not in r.applies_to:
+ if file_type not in r.applies_to:
continue
out.append(r)
return out
@@ -1087,12 +1087,12 @@ def select_rules(mode, input_kind):
# Block runner
# ---------------------------------------------------------------------------
-def check_block(text, mode, input_type):
+def check_block(text, mode, file_type):
"""Run all selected rules on a single block of DTS text. Returns a
list of (lineno, rule_name, message) tuples."""
lines = classify_lines(text)
- ctx = Ctx(lines, text, mode, input_type)
- rules = select_rules(mode, input_type)
+ ctx = Ctx(lines, text, mode, file_type)
+ rules = select_rules(mode, file_type)
findings = []
for r in rules:
for lineno, msg in r.check(ctx):
@@ -1149,7 +1149,7 @@ def iter_dts_file(filepath):
# Top-level processing
# ---------------------------------------------------------------------------
-def input_kind(filepath):
+def get_file_type(filepath):
p = filepath.lower()
if p.endswith('.yaml') or p.endswith('.yml'):
return 'yaml'
@@ -1169,17 +1169,17 @@ DTS_FAMILY = ('dts', 'dtsi', 'dtso')
def collect_findings(filepath, mode):
"""Return a (lines, count) pair for filepath. lines is a list of
formatted output strings; count is the number of findings."""
- kind = input_kind(filepath)
- if kind == 'yaml':
+ file_type = get_file_type(filepath)
+ if file_type == 'yaml':
iterator = iter_yaml_examples(filepath)
- elif kind in DTS_FAMILY:
+ elif file_type in DTS_FAMILY:
iterator = iter_dts_file(filepath)
else:
return (['%s: unknown file type, skipping' % filepath], 0)
out = []
for text, base, idx in iterator:
- for lineno, rule, msg in check_block(text, mode, kind):
+ for lineno, rule, msg in check_block(text, mode, file_type):
abs_line = base + lineno - 1
ex_tag = '' if idx is None else ' example %d' % idx
out.append('%s:%d:%s [%s] %s' %
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v4 05/10] dtc: dt-check-style: Introduce 'stricter' mode
2026-08-26 7:05 [PATCH v4 00/10] dtc: dt-check-style: Improvements for false positives Krzysztof Kozlowski
` (3 preceding siblings ...)
2026-08-26 7:05 ` [PATCH v4 04/10] dtc: dt-check-style: Consistently call 'kind' as 'file_type' Krzysztof Kozlowski
@ 2026-08-26 7:05 ` Krzysztof Kozlowski
2026-08-26 7:05 ` [PATCH v4 06/10] dtc: dt-check-style: Replace Test User email with Rob Herring Krzysztof Kozlowski
` (4 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Krzysztof Kozlowski @ 2026-08-26 7:05 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Krzysztof Kozlowski, Conor Dooley
Cc: devicetree, linux-kernel, Krzysztof Kozlowski
Two rules, which are enabled in 'strict' mode make little sense for DTS:
1. line-length, limiting length of line to 80 characters: DTS often has
a bit longer lines, especially for interconnects or heavily nested
opp-level. Checkpatch already does not warn for exceeding 80
characters.
2. unused-labels, discouraging unused labels in DTS or YAML (not DTSI or
DTSO): while not harming this leads to many false positives, e.g.
unused PMIC regulators in DTS.
Introduce another 'mode' of running beside existing relaxed and strict:
a 'stricter' one where these two rules are moved for DTS. Intention is
to have in-tree DTS passing 'strict' mode.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
scripts/dtc/dt-check-style | 25 +++++++++++++++-------
.../dtc/dt-style-selftest/bad/dts-line-length.dts | 21 ++++++++++++++++++
.../dtc/dt-style-selftest/bad/dts-unused-label.dts | 21 ++++++++++++++++++
.../expected/dts-line-length.dts.txt | 2 ++
.../expected/dts-unused-label.dts.txt | 2 ++
scripts/dtc/dt-style-selftest/run.sh | 2 +-
6 files changed, 64 insertions(+), 9 deletions(-)
diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style
index a8a3b6e0f7db..5da3df25c3fc 100755
--- a/scripts/dtc/dt-check-style
+++ b/scripts/dtc/dt-check-style
@@ -5,12 +5,14 @@
# .dts/.dtsi/.dtso source files. Enforces rules from
# Documentation/devicetree/bindings/dts-coding-style.rst.
#
-# Two modes:
+# Three modes:
# --mode=relaxed (default)
# Only rules that produce zero warnings on the current tree.
# Suitable for dt_binding_check.
# --mode=strict
-# All rules. Required for new submissions.
+# Most of the rules. Required for new submissions.
+# --mode=stricter
+# All rules, including ones having false positives.
#
# Two input types (auto-detected by file extension):
# *.yaml -- DT binding; check each example block
@@ -319,7 +321,7 @@ class Ctx:
def __init__(self, lines, text, mode, file_type):
self.lines = lines
self.text = text
- self.mode = mode # 'relaxed' or 'strict'
+ self.mode = mode # 'relaxed', 'strict' or 'stricter'
if file_type in DTS_FAMILY:
self.file_type = 'dts'
else:
@@ -332,7 +334,7 @@ class Rule:
def __init__(self, name, mode, description, check,
applies_to=('yaml', 'dts', 'dtsi', 'dtso')):
self.name = name
- self.mode = mode # 'relaxed' or 'strict'
+ self.mode = mode # 'relaxed', 'strict' or 'stricter'
self.description = description
self.check = check
self.applies_to = applies_to # input types this rule covers
@@ -1059,20 +1061,27 @@ RULES = [
check_node_close_alone),
Rule('line-length', 'strict',
'lines must not exceed 80 columns',
- check_line_length),
+ check_line_length, applies_to=('yaml',)),
+ Rule('line-length-dts', 'stricter',
+ 'lines must not exceed 80 columns',
+ check_line_length, applies_to=('dts', 'dtsi', 'dtso')),
Rule('continuation-alignment', 'strict',
'multi-line property continuations align under <, " or the value under <',
check_continuation_alignment),
Rule('unused-labels', 'strict',
'every label must be &-referenced in the same example/file '
'(skipped for .dtsi/.dtso since labels there are exported)',
- check_unused_labels, applies_to=('yaml', 'dts')),
+ check_unused_labels, applies_to=('yaml',)),
+ Rule('unused-labels-dts', 'stricter',
+ 'every label must be &-referenced in the same example/file '
+ '(skipped for .dtsi/.dtso since labels there are exported)',
+ check_unused_labels, applies_to=('dts',)),
]
def select_rules(mode, file_type):
"""Return rules that apply to the given mode and input type."""
- rank = {'relaxed': 0, 'strict': 1}
+ rank = {'relaxed': 0, 'strict': 1, 'stricter': 2}
out = []
for r in RULES:
if rank[r.mode] > rank[mode]:
@@ -1200,7 +1209,7 @@ def main():
description='Check DTS coding style on YAML examples and '
'.dts/.dtsi/.dtso files.',
fromfile_prefix_chars='@')
- ap.add_argument('--mode', choices=('relaxed', 'strict'),
+ ap.add_argument('--mode', choices=('relaxed', 'strict', 'stricter'),
default='relaxed',
help='which rule set to apply (default: relaxed)')
ap.add_argument('-j', '--jobs', type=int, default=0,
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-line-length.dts b/scripts/dtc/dt-style-selftest/bad/dts-line-length.dts
new file mode 100644
index 000000000000..bde91a922477
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/dts-line-length.dts
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/*
+ * Test fixture: Line length in DTS
+ */
+
+/dts-v1/;
+
+/ {
+ soc@0 {
+ compatible = "simple-bus";
+ ranges = <0 0 0 0xc0000000>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ foo@1000 {
+ compatible = "example,test-line-length-this-is-a-very-long-name-indeed-yeah";
+ reg = <0x1000 0x100>;
+ };
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-unused-label.dts b/scripts/dtc/dt-style-selftest/bad/dts-unused-label.dts
new file mode 100644
index 000000000000..90802ae107e1
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/dts-unused-label.dts
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/*
+ * Test fixture: Unused label in DTS
+ */
+
+/dts-v1/;
+
+/ {
+ soc@0 {
+ compatible = "simple-bus";
+ ranges = <0 0 0 0xc0000000>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ dev: device@1000 {
+ compatible = "example,test-unused-label";
+ 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
new file mode 100644
index 000000000000..8ed08c309632
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/dts-line-length.dts.txt
@@ -0,0 +1,2 @@
+# mode=stricter
+bad/dts-line-length.dts:17: [line-length-dts] line exceeds 80 columns (101)
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-unused-label.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-unused-label.dts.txt
new file mode 100644
index 000000000000..4cdcaba3ba2f
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/dts-unused-label.dts.txt
@@ -0,0 +1,2 @@
+# mode=stricter
+bad/dts-unused-label.dts:16: [unused-labels-dts] label 'dev' defined but never &-referenced
diff --git a/scripts/dtc/dt-style-selftest/run.sh b/scripts/dtc/dt-style-selftest/run.sh
index 8117dd9be90a..5691301d6a4a 100755
--- a/scripts/dtc/dt-style-selftest/run.sh
+++ b/scripts/dtc/dt-style-selftest/run.sh
@@ -26,7 +26,7 @@ run() {
# good/ -- must exit 0 and produce no output in both modes
for f in "$here"/good/*; do
[ -e "$f" ] || continue
- for mode in relaxed strict; do
+ for mode in relaxed strict stricter; do
out=$(run "$f" "$mode")
rc=$?
if [ -n "$out" ] || [ "$rc" -ne 0 ]; then
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v4 06/10] dtc: dt-check-style: Replace Test User email with Rob Herring
2026-08-26 7:05 [PATCH v4 00/10] dtc: dt-check-style: Improvements for false positives Krzysztof Kozlowski
` (4 preceding siblings ...)
2026-08-26 7:05 ` [PATCH v4 05/10] dtc: dt-check-style: Introduce 'stricter' mode Krzysztof Kozlowski
@ 2026-08-26 7:05 ` Krzysztof Kozlowski
2026-08-26 7:06 ` [PATCH v4 07/10] dtc: dt-check-style: Call _strip_strings_and_comments() only once Krzysztof Kozlowski
` (3 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Krzysztof Kozlowski @ 2026-08-26 7:05 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Krzysztof Kozlowski, Conor Dooley
Cc: devicetree, linux-kernel, Krzysztof Kozlowski
scripts/get_maintainer.pl reports email from the example binding
fixtures, so let's spare someone at @example.com from receiving bunch
of odd emails.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
scripts/dtc/dt-style-selftest/bad/yaml-child-addr-order.yaml | 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-child-name-order.yaml | 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-cont-align.yaml | 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-digit-node-order.yaml | 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-hex-case.yaml | 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-indent-strict.yaml | 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-label-in-string.yaml | 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-line-length.yaml | 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-mixed-indent.yaml | 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-multi-close.yaml | 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-node-close.yaml | 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-prop-order-device-type.yaml | 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-prop-order.yaml | 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-prop-pairing.yaml | 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-required-blank.yaml | 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-tab.yaml | 2 +-
| 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-trailing-ws.yaml | 2 +-
| 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-unit-addr-prefix.yaml | 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-unit-addr.yaml | 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-unused-label.yaml | 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-value-ws-multiline.yaml | 2 +-
scripts/dtc/dt-style-selftest/bad/yaml-value-ws.yaml | 2 +-
scripts/dtc/dt-style-selftest/good/yaml-4space.yaml | 2 +-
scripts/dtc/dt-style-selftest/good/yaml-cont-align.yaml | 2 +-
scripts/dtc/dt-style-selftest/good/yaml-tricky-parsing.yaml | 2 +-
27 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-child-addr-order.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-child-addr-order.yaml
index 3df56e69a1ff..7c3b731e059a 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-child-addr-order.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-child-addr-order.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture with addressed children out of order
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-child-name-order.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-child-name-order.yaml
index 35d85e5573c2..f3483033859a 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-child-name-order.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-child-name-order.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture with unaddressed children out of name order
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-cont-align.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-cont-align.yaml
index d4662acc7b8f..ebb35deabbd5 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-cont-align.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-cont-align.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture with mis-aligned multi-line property
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-digit-node-order.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-digit-node-order.yaml
index 44a9d25e5ba0..068542a98576 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-digit-node-order.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-digit-node-order.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture with digit-leading nodes out of address order
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-hex-case.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-hex-case.yaml
index b26d1bf58de9..c55359a4ca68 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-hex-case.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-hex-case.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture with uppercase hex literals
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-indent-strict.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-indent-strict.yaml
index bee4cf118d73..155060a79887 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-indent-strict.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-indent-strict.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture using 2-space indent (rejected by strict mode)
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-label-in-string.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-label-in-string.yaml
index ba512869b702..4a69b503af4b 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-label-in-string.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-label-in-string.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture where a label is only "referenced" inside a string
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
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 64427bf1c385..6e4140e500b5 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-line-length.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-line-length.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture exceeding 80 columns
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-mixed-indent.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-mixed-indent.yaml
index 5401d1a423a1..c25a0d1a999e 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-mixed-indent.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-mixed-indent.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture mixing tabs and spaces in indent
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
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 4d9fa27b50a2..afc202a698eb 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-multi-close.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-multi-close.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture with two closing braces on one line
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-node-close.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-node-close.yaml
index e107659fd9e8..9e714f7e7d47 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-node-close.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-node-close.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture with closing brace not on its own line
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-prop-order-device-type.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-prop-order-device-type.yaml
index e2c69e9ff452..c71fb2c0a3e5 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-prop-order-device-type.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-prop-order-device-type.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture with device_type
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-prop-order.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-prop-order.yaml
index 75582a3d2f6e..bf1480e97209 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-prop-order.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-prop-order.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture with reg before compatible
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-prop-pairing.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-prop-pairing.yaml
index 767ab21c39f3..51abc540af11 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-prop-pairing.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-prop-pairing.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture exercising <x>-names and pinctrl-names pairing
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-required-blank.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-required-blank.yaml
index 8bb53240cffa..0036d5e0c4ea 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-required-blank.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-required-blank.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture missing required blank lines
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-tab.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-tab.yaml
index 487d07ff8cb6..937ecdd923b0 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-tab.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-tab.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture with a tab in a DTS line
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
--git a/scripts/dtc/dt-style-selftest/bad/yaml-trailing-comment.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-trailing-comment.yaml
index 2368ada8106f..695d046e8454 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-trailing-comment.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-trailing-comment.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture with properties out of order behind trailing comments
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
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 5c4b4bd833c5..f338c14174e6 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-trailing-ws.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-trailing-ws.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture with trailing whitespace
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
--git a/scripts/dtc/dt-style-selftest/bad/yaml-unclosed-comment.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-unclosed-comment.yaml
index 63c1c08712a5..191ed775384b 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-unclosed-comment.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-unclosed-comment.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture with an unclosed /* block comment
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-unit-addr-prefix.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-unit-addr-prefix.yaml
index 9b3fe508c5fd..62590948d2de 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-unit-addr-prefix.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-unit-addr-prefix.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture with 0x-prefixed unit address
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-unit-addr.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-unit-addr.yaml
index 93705cd45410..5bb19fba5c19 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-unit-addr.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-unit-addr.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture with malformed unit address
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-unused-label.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-unused-label.yaml
index 28d7176cbf08..7f862ae5a175 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-unused-label.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-unused-label.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture with an unused label
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-value-ws-multiline.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-value-ws-multiline.yaml
index 504bf0931c27..1d7bc8142fd7 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-value-ws-multiline.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-value-ws-multiline.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture with extra whitespace in a multi-line cell array
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-value-ws.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-value-ws.yaml
index 342ab9f399f1..a5082a158155 100644
--- a/scripts/dtc/dt-style-selftest/bad/yaml-value-ws.yaml
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-value-ws.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture with extra whitespace inside <...>
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/good/yaml-4space.yaml b/scripts/dtc/dt-style-selftest/good/yaml-4space.yaml
index 1502f803c24c..b91b8a8a9512 100644
--- a/scripts/dtc/dt-style-selftest/good/yaml-4space.yaml
+++ b/scripts/dtc/dt-style-selftest/good/yaml-4space.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture for dt-check-style
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/good/yaml-cont-align.yaml b/scripts/dtc/dt-style-selftest/good/yaml-cont-align.yaml
index 2e7b8582bb7c..8463075f9f4c 100644
--- a/scripts/dtc/dt-style-selftest/good/yaml-cont-align.yaml
+++ b/scripts/dtc/dt-style-selftest/good/yaml-cont-align.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Test fixture with aligned multi-line property
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
diff --git a/scripts/dtc/dt-style-selftest/good/yaml-tricky-parsing.yaml b/scripts/dtc/dt-style-selftest/good/yaml-tricky-parsing.yaml
index a836d5f36b93..a95d07f883ef 100644
--- a/scripts/dtc/dt-style-selftest/good/yaml-tricky-parsing.yaml
+++ b/scripts/dtc/dt-style-selftest/good/yaml-tricky-parsing.yaml
@@ -17,7 +17,7 @@ description: |
not leave the parser in block-comment state.
maintainers:
- - Test User <test@example.com>
+ - Rob Herring <robh@kernel.org>
properties:
compatible:
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v4 07/10] dtc: dt-check-style: Call _strip_strings_and_comments() only once
2026-08-26 7:05 [PATCH v4 00/10] dtc: dt-check-style: Improvements for false positives Krzysztof Kozlowski
` (5 preceding siblings ...)
2026-08-26 7:05 ` [PATCH v4 06/10] dtc: dt-check-style: Replace Test User email with Rob Herring Krzysztof Kozlowski
@ 2026-08-26 7:06 ` Krzysztof Kozlowski
2026-08-26 7:06 ` [PATCH v4 08/10] dtc: dt-check-style: Add test for trailing white-space in DTS Krzysztof Kozlowski
` (2 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Krzysztof Kozlowski @ 2026-08-26 7:06 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Krzysztof Kozlowski, Conor Dooley
Cc: devicetree, linux-kernel, Krzysztof Kozlowski
More than one rule evaluates pure code - stripped from comments and
indentation - thus store this pure code in DtsLine class for
better performance.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
scripts/dtc/dt-check-style | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style
index 5da3df25c3fc..dd3828b14638 100755
--- a/scripts/dtc/dt-check-style
+++ b/scripts/dtc/dt-check-style
@@ -79,18 +79,19 @@ def is_preprocessor(stripped):
class DtsLine:
- __slots__ = ('lineno', 'raw', 'linetype', 'indent_str', 'stripped', 'is_root',
+ __slots__ = ('lineno', 'raw', 'code', 'linetype', 'indent_str', 'stripped', 'is_root',
'prop_name', 'continuations',
'node_name', 'node_addr', 'label', 'ref_name', 'parent', 'depth',
'closures')
def __init__(self, lineno, raw, linetype, depth, indent_str, stripped, is_root = False):
self.lineno = lineno # 1-based within the block
- self.raw = raw
+ self.raw = raw # Entire raw line
self.linetype = linetype
self.indent_str = indent_str # leading whitespace as-is
self.depth = depth
- self.stripped = stripped
+ self.stripped = stripped # Code without indentation
+ self.code = _strip_strings_and_comments(stripped) # Only the code, skipping trailing comments
self.is_root = is_root
self.prop_name = None
self.continuations = []
@@ -811,8 +812,7 @@ def check_hex_case(ctx):
LineType.COMMENT_START, LineType.COMMENT_BODY,
LineType.COMMENT_END, LineType.PREPROCESSOR):
continue
- text = _strip_strings_and_comments(dl.raw)
- for m in re.finditer(r'\b0[xX][0-9a-fA-F]+\b', text):
+ for m in re.finditer(r'\b0[xX][0-9a-fA-F]+\b', dl.code):
lit = m.group(0)
if any(c.isupper() for c in lit[2:]) or lit[1] == 'X':
yield (dl.lineno,
@@ -860,9 +860,9 @@ def check_value_whitespace(ctx):
for dl in ctx.lines:
if dl.linetype != LineType.PROPERTY:
continue
- segs = [_strip_strings_and_comments(dl.raw).strip()]
+ segs = [dl.code]
for cont in dl.continuations:
- segs.append(_strip_strings_and_comments(cont.stripped).strip())
+ segs.append(cont.code)
text = ''
for s in segs:
if not s:
@@ -895,8 +895,7 @@ def check_node_close_alone(ctx):
LineType.COMMENT_START, LineType.COMMENT_BODY,
LineType.COMMENT_END, LineType.PREPROCESSOR):
continue
- text = _strip_strings_and_comments(dl.raw)
- if '};' in text:
+ if '};' in dl.code:
yield (dl.lineno,
'closing brace must be on its own line')
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v4 08/10] dtc: dt-check-style: Add test for trailing white-space in DTS
2026-08-26 7:05 [PATCH v4 00/10] dtc: dt-check-style: Improvements for false positives Krzysztof Kozlowski
` (6 preceding siblings ...)
2026-08-26 7:06 ` [PATCH v4 07/10] dtc: dt-check-style: Call _strip_strings_and_comments() only once Krzysztof Kozlowski
@ 2026-08-26 7:06 ` Krzysztof Kozlowski
2026-08-26 7:06 ` [PATCH v4 09/10] dtc: dt-check-style: Add warning for redundant white-spaces Krzysztof Kozlowski
2026-08-26 7:06 ` [PATCH v4 10/10] MAINTAINERS: dt-bindings: Include dt-check-style in DT binding entry Krzysztof Kozlowski
9 siblings, 0 replies; 15+ messages in thread
From: Krzysztof Kozlowski @ 2026-08-26 7:06 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Krzysztof Kozlowski, Conor Dooley
Cc: devicetree, linux-kernel, Krzysztof Kozlowski
Add unit tests for expected warnings for trailing white-spaces in DTS
(there is only one for YAML files).
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
scripts/dtc/dt-style-selftest/bad/dts-trailing-ws.dts | 8 ++++++++
scripts/dtc/dt-style-selftest/expected/dts-trailing-ws.dts.txt | 2 ++
2 files changed, 10 insertions(+)
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-trailing-ws.dts b/scripts/dtc/dt-style-selftest/bad/dts-trailing-ws.dts
new file mode 100644
index 000000000000..1eb24d91c640
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/dts-trailing-ws.dts
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+
+/ {
+ compatible = "example,test-board";
+ #address-cells = <1>;
+ #size-cells = <1>;
+};
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
new file mode 100644
index 000000000000..94d9ae9d616c
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/dts-trailing-ws.dts.txt
@@ -0,0 +1,2 @@
+# mode=relaxed
+bad/dts-trailing-ws.dts:5: [trailing-whitespace] trailing whitespace
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v4 09/10] dtc: dt-check-style: Add warning for redundant white-spaces
2026-08-26 7:05 [PATCH v4 00/10] dtc: dt-check-style: Improvements for false positives Krzysztof Kozlowski
` (7 preceding siblings ...)
2026-08-26 7:06 ` [PATCH v4 08/10] dtc: dt-check-style: Add test for trailing white-space in DTS Krzysztof Kozlowski
@ 2026-08-26 7:06 ` Krzysztof Kozlowski
2026-08-26 7:18 ` sashiko-bot
2026-08-26 7:06 ` [PATCH v4 10/10] MAINTAINERS: dt-bindings: Include dt-check-style in DT binding entry Krzysztof Kozlowski
9 siblings, 1 reply; 15+ messages in thread
From: Krzysztof Kozlowski @ 2026-08-26 7:06 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Krzysztof Kozlowski, Conor Dooley
Cc: devicetree, linux-kernel, Krzysztof Kozlowski
Show warnings of too many spaces around '=', before '{' and ';'
characters, or using tabs for these. Both in-tree DTS and DT bindings
have many warnings for the first case (too mant spaces around '='), thus
keep this one only for 'strict' mode.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
scripts/dtc/dt-check-style | 38 ++++++++++++++++++++++
.../bad/dts-redundant-ws-strict.dts | 27 +++++++++++++++
.../dtc/dt-style-selftest/bad/dts-redundant-ws.dts | 27 +++++++++++++++
.../bad/yaml-redundant-ws-strict.yaml | 31 ++++++++++++++++++
.../dt-style-selftest/bad/yaml-redundant-ws.yaml | 34 +++++++++++++++++++
.../expected/dts-property-order.dts.txt | 1 +
.../expected/dts-redundant-ws-strict.dts.txt | 13 ++++++++
.../expected/dts-redundant-ws.dts.txt | 9 +++++
.../expected/yaml-redundant-ws-strict.yaml.txt | 5 +++
.../expected/yaml-redundant-ws.yaml.txt | 3 ++
10 files changed, 188 insertions(+)
diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style
index dd3828b14638..e67ba1e5164a 100755
--- a/scripts/dtc/dt-check-style
+++ b/scripts/dtc/dt-check-style
@@ -349,6 +349,36 @@ def check_trailing_whitespace(ctx):
yield (dl.lineno, 'trailing whitespace')
+def check_redundant_whitespace(ctx):
+ """No whitespace between brackets or other code elements.
+ See also check_value_whitespace() for more checks."""
+ for dl in ctx.lines:
+ if dl.linetype in (LineType.COMMENT, LineType.COMMENT_BODY,
+ LineType.COMMENT_END, LineType.COMMENT_START,
+ LineType.PREPROCESSOR):
+ continue
+ if re.search(r'(\s\s+|\t){', dl.code):
+ yield (dl.lineno, 'extra whitespace before {')
+ if re.search(r':(\s\s+|\t)', dl.code):
+ yield (dl.lineno, 'extra whitespace after :')
+ if re.search(r'\s+;', dl.code):
+ yield (dl.lineno, 'extra whitespace before ;')
+
+
+def check_redundant_whitespace_strict(ctx):
+ """No whitespace between brackets or other code elements.
+ See also check_value_whitespace() for more checks."""
+ for dl in ctx.lines:
+ if dl.linetype in (LineType.COMMENT, LineType.COMMENT_BODY,
+ LineType.COMMENT_END, LineType.COMMENT_START,
+ LineType.PREPROCESSOR):
+ continue
+ if re.search(r'(\s\s+|\t)=', dl.code):
+ yield (dl.lineno, 'extra whitespace before =')
+ if re.search(r'=(\s\s+|\t)', dl.code):
+ yield (dl.lineno, 'extra whitespace after =')
+
+
def check_tab_in_yaml_example(ctx):
"""Reject literal tabs in DTS lines when input is YAML.
@@ -1002,6 +1032,10 @@ RULES = [
Rule('trailing-whitespace', 'relaxed',
'no trailing whitespace on any line',
check_trailing_whitespace),
+ # See also check_redundant_whitespace_strict() and check_value_whitespace()
+ Rule('redundant-whitespace', 'relaxed',
+ 'no redundant whitespace within code',
+ check_redundant_whitespace),
Rule('tab-in-yaml', 'relaxed',
'YAML (also DTS examples) may not contain tab characters',
check_tab_in_yaml_example, applies_to=('yaml',)),
@@ -1052,6 +1086,10 @@ RULES = [
Rule('unit-address-format', 'strict',
'unit addresses must be lowercase hex without leading zeros',
check_unit_address_format),
+ # See also check_redundant_whitespace() and check_value_whitespace()
+ Rule('redundant-whitespace-strict', 'strict',
+ 'no redundant whitespace within code',
+ check_redundant_whitespace_strict),
Rule('value-whitespace', 'strict',
'no whitespace directly inside <...> brackets',
check_value_whitespace),
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-redundant-ws-strict.dts b/scripts/dtc/dt-style-selftest/bad/dts-redundant-ws-strict.dts
new file mode 100644
index 000000000000..201e3940ba1c
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/dts-redundant-ws-strict.dts
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+
+#define SOME_MACRO(foo) \
+ (foo) ? <1> : <2> ;
+
+/ {
+ compatible = "example,test-board";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ /* comments { are okay = though ; */
+ soc: soc@0 { /* comments { are okay = though ; */
+ compatible = "simple-bus"; /* comments { are okay = though ; */
+ ranges = <0 0 0 0xc0000000>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+ } ;
+}; /* comments { are okay = though ; */
+
+&soc {
+ serial: serial@20000 { /* comments { are okay = though ; */
+ compatible = "example,serial";
+ reg = <0x20000 0x1000>;
+ } ;
+};
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-redundant-ws.dts b/scripts/dtc/dt-style-selftest/bad/dts-redundant-ws.dts
new file mode 100644
index 000000000000..de1f383571d2
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/dts-redundant-ws.dts
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/dts-v1/;
+
+#define SOME_MACRO(foo) \
+ (foo) ? <1> : <2> ;
+
+/ {
+ compatible = "example,test-board";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ /* comments { are okay = though ; */
+ soc: soc@0 { /* comments { are okay = though ; */
+ compatible = "simple-bus"; /* comments { are okay = though ; */
+ ranges = <0 0 0 0xc0000000>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+ } ;
+}; /* comments { are okay = though ; */
+
+&soc {
+ serial: serial@20000 { /* comments { are okay = though ; */
+ compatible = "example,serial";
+ reg = <0x20000 0x1000>;
+ } ;
+};
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-redundant-ws-strict.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-redundant-ws-strict.yaml
new file mode 100644
index 000000000000..739c44fd7217
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-redundant-ws-strict.yaml
@@ -0,0 +1,31 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/yaml-redundant-ws-strict.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Test fixture with redundant whitespace
+
+maintainers:
+ - Rob Herring <robh@kernel.org>
+
+properties:
+ compatible:
+ const: example,test-redundant
+ reg:
+ maxItems: 1
+
+required:
+ - compatible
+ - reg
+
+additionalProperties: false
+
+examples:
+ - |
+ device@1000 {
+ compatible = "example,test-trailing";
+ reg = <0x1000 0x100>;
+ clocks = <&clk 0>; /* comments { are okay = though ; */
+ clock-names = "bus"; /* comments { are okay = though ; */
+ } ;
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-redundant-ws.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-redundant-ws.yaml
new file mode 100644
index 000000000000..92ddfddaf5c0
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-redundant-ws.yaml
@@ -0,0 +1,34 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/yaml-redundant-ws.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Test fixture with redundant whitespace
+
+maintainers:
+ - Rob Herring <robh@kernel.org>
+
+properties:
+ compatible:
+ const: example,test-redundant
+ reg:
+ maxItems: 1
+
+required:
+ - compatible
+ - reg
+
+additionalProperties: false
+
+examples:
+ - |
+ device@1000 { /* comments { are okay = though ; */
+ compatible = "example,test-trailing";
+ reg = <0x1000 0x100>;
+ } ;
+
+ device@2000 { /* comments { are okay = though ; */
+ compatible = "example,test-trailing";
+ reg = <0x2000 0x100>;
+ }; /* comments { are okay = though ; */
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-property-order.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-property-order.dts.txt
index 65977f96331d..29283f3451c7 100644
--- a/scripts/dtc/dt-style-selftest/expected/dts-property-order.dts.txt
+++ b/scripts/dtc/dt-style-selftest/expected/dts-property-order.dts.txt
@@ -1,4 +1,5 @@
# mode=strict
+bad/dts-property-order.dts:8: [redundant-whitespace] extra whitespace before {
bad/dts-property-order.dts:10: [property-order] property 'model' out of canonical order (should sort before 'compatible')
bad/dts-property-order.dts:12: [property-order] property 'chassis-type' out of canonical order (should sort before 'qcom,board-id')
bad/dts-property-order.dts:20: [property-order] property 'compatible' out of canonical order (should sort before 'reg')
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-redundant-ws-strict.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-redundant-ws-strict.dts.txt
new file mode 100644
index 000000000000..ac0d57bdecdf
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/dts-redundant-ws-strict.dts.txt
@@ -0,0 +1,13 @@
+# mode=strict
+bad/dts-redundant-ws-strict.dts:7: [redundant-whitespace] extra whitespace before {
+bad/dts-redundant-ws-strict.dts:13: [redundant-whitespace] extra whitespace before {
+bad/dts-redundant-ws-strict.dts:13: [redundant-whitespace] extra whitespace after :
+bad/dts-redundant-ws-strict.dts:17: [redundant-whitespace-strict] extra whitespace before =
+bad/dts-redundant-ws-strict.dts:18: [redundant-whitespace-strict] extra whitespace after =
+bad/dts-redundant-ws-strict.dts:19: [redundant-whitespace] extra whitespace before ;
+bad/dts-redundant-ws-strict.dts:22: [redundant-whitespace] extra whitespace before {
+bad/dts-redundant-ws-strict.dts:23: [redundant-whitespace] extra whitespace before {
+bad/dts-redundant-ws-strict.dts:23: [redundant-whitespace] extra whitespace after :
+bad/dts-redundant-ws-strict.dts:24: [redundant-whitespace-strict] extra whitespace before =
+bad/dts-redundant-ws-strict.dts:25: [redundant-whitespace-strict] extra whitespace after =
+bad/dts-redundant-ws-strict.dts:26: [redundant-whitespace] extra whitespace before ;
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-redundant-ws.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-redundant-ws.dts.txt
new file mode 100644
index 000000000000..c18c1972bb47
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/dts-redundant-ws.dts.txt
@@ -0,0 +1,9 @@
+# mode=relaxed
+bad/dts-redundant-ws.dts:7: [redundant-whitespace] extra whitespace before {
+bad/dts-redundant-ws.dts:13: [redundant-whitespace] extra whitespace before {
+bad/dts-redundant-ws.dts:13: [redundant-whitespace] extra whitespace after :
+bad/dts-redundant-ws.dts:19: [redundant-whitespace] extra whitespace before ;
+bad/dts-redundant-ws.dts:22: [redundant-whitespace] extra whitespace before {
+bad/dts-redundant-ws.dts:23: [redundant-whitespace] extra whitespace before {
+bad/dts-redundant-ws.dts:23: [redundant-whitespace] extra whitespace after :
+bad/dts-redundant-ws.dts:26: [redundant-whitespace] extra whitespace before ;
diff --git a/scripts/dtc/dt-style-selftest/expected/yaml-redundant-ws-strict.yaml.txt b/scripts/dtc/dt-style-selftest/expected/yaml-redundant-ws-strict.yaml.txt
new file mode 100644
index 000000000000..fbf323832c91
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/yaml-redundant-ws-strict.yaml.txt
@@ -0,0 +1,5 @@
+# mode=strict
+bad/yaml-redundant-ws-strict.yaml:26: example 0 [redundant-whitespace] extra whitespace before {
+bad/yaml-redundant-ws-strict.yaml:27: example 0 [redundant-whitespace-strict] extra whitespace before =
+bad/yaml-redundant-ws-strict.yaml:28: example 0 [redundant-whitespace-strict] extra whitespace after =
+bad/yaml-redundant-ws-strict.yaml:31: example 0 [redundant-whitespace] extra whitespace before ;
diff --git a/scripts/dtc/dt-style-selftest/expected/yaml-redundant-ws.yaml.txt b/scripts/dtc/dt-style-selftest/expected/yaml-redundant-ws.yaml.txt
new file mode 100644
index 000000000000..c85e80ed272a
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/yaml-redundant-ws.yaml.txt
@@ -0,0 +1,3 @@
+# mode=relaxed
+bad/yaml-redundant-ws.yaml:26: example 0 [redundant-whitespace] extra whitespace before {
+bad/yaml-redundant-ws.yaml:29: example 0 [redundant-whitespace] extra whitespace before ;
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH v4 09/10] dtc: dt-check-style: Add warning for redundant white-spaces
2026-08-26 7:06 ` [PATCH v4 09/10] dtc: dt-check-style: Add warning for redundant white-spaces Krzysztof Kozlowski
@ 2026-08-26 7:18 ` sashiko-bot
2026-08-26 8:56 ` Krzysztof Kozlowski
0 siblings, 1 reply; 15+ messages in thread
From: sashiko-bot @ 2026-08-26 7:18 UTC (permalink / raw)
To: Krzysztof Kozlowski; +Cc: robh, conor+dt, devicetree
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The regular expression `r'(\s\s+|\t){'` uses an unescaped `{` character immediately after a capturing group. In Python 3.11+, the `re` module enforces strict parsing and treats this as a malformed repetition operator, raising `re.error`. This unconditionally crashes the `dt-check-style` script upon execution.
- [Low] The redundant whitespace checks do not validate continuation lines of multi-line properties, causing them to silently miss styling violations.
--
commit 2e1d4b87b1d575d09206e54554a02623ac0f7700
Author: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
dtc: dt-check-style: Add warning for redundant white-spaces
Show warnings of too many spaces around '=', before '{' and ';' characters,
or using tabs for these. Both in-tree DTS and DT bindings have many warnings
for the first case, thus keep this one only for 'strict' mode.
> diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style
> index dd3828b146385..e67ba1e5164a7 100755
> --- a/scripts/dtc/dt-check-style
> +++ b/scripts/dtc/dt-check-style
> @@ -349,6 +349,36 @@ def check_trailing_whitespace(ctx):
> yield (dl.lineno, 'trailing whitespace')
>
>
> +def check_redundant_whitespace(ctx):
> + """No whitespace between brackets or other code elements.
> + See also check_value_whitespace() for more checks."""
> + for dl in ctx.lines:
[Severity: Low]
Does this code silently miss styling violations on multi-line properties?
Because the loop only iterates over ctx.lines, it appears to bypass nested
continuation lines (dl.continuations). If a violation, such as extra spaces
before a semicolon, occurs on a continuation line, it won't be checked.
> + if dl.linetype in (LineType.COMMENT, LineType.COMMENT_BODY,
> + LineType.COMMENT_END, LineType.COMMENT_START,
> + LineType.PREPROCESSOR):
> + continue
> + if re.search(r'(\s\s+|\t){', dl.code):
[Severity: High]
Does this unescaped curly brace crash the script in newer Python versions?
In Python 3.11+, the re module enforces strict parsing and treats an
unescaped { immediately after a capturing group as a malformed repetition
operator, raising re.error. This will break the dt_binding_check build
process unconditionally for users on newer Python versions.
> + yield (dl.lineno, 'extra whitespace before {')
> + if re.search(r':(\s\s+|\t)', dl.code):
> + yield (dl.lineno, 'extra whitespace after :')
> + if re.search(r'\s+;', dl.code):
> + yield (dl.lineno, 'extra whitespace before ;')
> +
> +
> +def check_redundant_whitespace_strict(ctx):
> + """No whitespace between brackets or other code elements.
> + See also check_value_whitespace() for more checks."""
> + for dl in ctx.lines:
[Severity: Low]
Is there a similar issue here with skipping continuation lines?
Like check_redundant_whitespace, this strict check loop ignores
continuation lines, meaning violations on multi-line properties will
be missed here as well.
> + if dl.linetype in (LineType.COMMENT, LineType.COMMENT_BODY,
> + LineType.COMMENT_END, LineType.COMMENT_START,
> + LineType.PREPROCESSOR):
> + continue
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260826-n-dts-style-checker-continued-v4-0-022e60091965@oss.qualcomm.com?part=9
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v4 09/10] dtc: dt-check-style: Add warning for redundant white-spaces
2026-08-26 7:18 ` sashiko-bot
@ 2026-08-26 8:56 ` Krzysztof Kozlowski
0 siblings, 0 replies; 15+ messages in thread
From: Krzysztof Kozlowski @ 2026-08-26 8:56 UTC (permalink / raw)
To: sashiko-reviews; +Cc: robh, conor+dt, devicetree
On 26/08/2026 09:18, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [High] The regular expression `r'(\s\s+|\t){'` uses an unescaped `{` character immediately after a capturing group. In Python 3.11+, the `re` module enforces strict parsing and treats this as a malformed repetition operator, raising `re.error`. This unconditionally crashes the `dt-check-style` script upon execution.
Ack
> - [Low] The redundant whitespace checks do not validate continuation lines of multi-line properties, causing them to silently miss styling violations.
Ack
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v4 10/10] MAINTAINERS: dt-bindings: Include dt-check-style in DT binding entry
2026-08-26 7:05 [PATCH v4 00/10] dtc: dt-check-style: Improvements for false positives Krzysztof Kozlowski
` (8 preceding siblings ...)
2026-08-26 7:06 ` [PATCH v4 09/10] dtc: dt-check-style: Add warning for redundant white-spaces Krzysztof Kozlowski
@ 2026-08-26 7:06 ` Krzysztof Kozlowski
9 siblings, 0 replies; 15+ messages in thread
From: Krzysztof Kozlowski @ 2026-08-26 7:06 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Krzysztof Kozlowski, Conor Dooley
Cc: devicetree, linux-kernel, Krzysztof Kozlowski
The dt-check-style tool is in interest of Devicetree bindings
maintainers, not only the driver OF-core (where it is covered through
"F: scripts/dtc/"), because it covers the DTS and the bindings. Add it
to the DT bindings maintainers entry.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
MAINTAINERS | 2 ++
1 file changed, 2 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index fe10d29b7657..59ec34fc9682 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -20488,6 +20488,8 @@ F: Documentation/devicetree/
F: Documentation/process/maintainer-devicetree.rst
F: arch/*/boot/dts/
F: include/dt-bindings/
+F: scripts/dtc/dt-check-style
+F: scripts/dtc/dt-style-selftest/
OPENCOMPUTE PTP CLOCK DRIVER
M: Vadim Fedorenko <vadim.fedorenko@linux.dev>
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread