[PATCH 8/9] dtc: dt-check-style: Introduce 'stricter' mode
From: Krzysztof Kozlowski
Date: Sun Jul 26 2026 - 11:49:11 EST
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@xxxxxxxxxxxxxxxx>
---
scripts/dtc/dt-check-style | 26 +++++++++++++++-------
.../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 ++
5 files changed, 64 insertions(+), 8 deletions(-)
diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style
index 8c049c04b865..7e1d80ceab78 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,8 @@ class Rule:
def __init__(self, name, mode, description, check,
applies_to=('yaml', 'dts', 'dtsi', 'dtso')):
self.name = name
- self.mode = mode # 'relaxed' or 'strict'
+ # 'relaxed', 'strict', 'stricter' ordictionary mapping file_type to mode
+ self.mode = mode
self.description = description
self.check = check
self.applies_to = applies_to # input types this rule covers
@@ -1042,20 +1045,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 "\\""',
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]:
@@ -1183,7 +1193,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..d1dacc5c76fb
--- /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: Unused label 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
--
2.53.0