summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>2026-09-11 13:42:05 +0200
committerRob Herring (Arm) <robh@kernel.org>2026-09-16 16:18:09 -0500
commit117d30d3107afcdbb5e681aadbd86d925675c0e2 (patch)
tree72e851e2ba4919b9b115a8ef39d721db670f1255 /scripts
parentd5eefb1d97ad476c734997fa6741651dde610ceb (diff)
dtc: dt-check-style: Handle multiple blank lines in continued properties
Properly ignore comments and report duplicated blank lines in multi-line properties. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260911-dts-style-checker-blank-lines-v1-2-85e779600d98@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/dtc/dt-check-style6
-rw-r--r--scripts/dtc/dt-style-selftest/bad/dts-blank-lines.dts37
-rw-r--r--scripts/dtc/dt-style-selftest/bad/yaml-blank-lines.yaml54
-rw-r--r--scripts/dtc/dt-style-selftest/expected/dts-blank-lines.dts.txt6
-rw-r--r--scripts/dtc/dt-style-selftest/expected/yaml-blank-lines.yaml.txt6
5 files changed, 109 insertions, 0 deletions
diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style
index 46aa4dda6d33..6bbd12b308a1 100755
--- a/scripts/dtc/dt-check-style
+++ b/scripts/dtc/dt-check-style
@@ -440,6 +440,12 @@ def check_blank_lines(ctx):
if lines[i].linetype == LineType.BLANK and \
lines[i - 1].linetype == LineType.BLANK:
yield (lines[i].lineno, 'consecutive blank lines')
+ prev_is_blank = lines[i].linetype == LineType.BLANK
+ for cont in lines[i].continuations:
+ if cont.linetype == LineType.BLANK and prev_is_blank:
+ yield (cont.lineno, 'consecutive blank lines')
+ prev_is_blank = cont.linetype == LineType.BLANK
+
# Blank right after { or right before }
for i, dl in enumerate(lines):
if dl.linetype != LineType.BLANK:
diff --git a/scripts/dtc/dt-style-selftest/bad/dts-blank-lines.dts b/scripts/dtc/dt-style-selftest/bad/dts-blank-lines.dts
new file mode 100644
index 000000000000..f2e99fb7bb29
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/dts-blank-lines.dts
@@ -0,0 +1,37 @@
+// 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>;
+
+ clocks = <1 2 3>,
+
+
+ /* Comment is not a blank line */
+ <4 5 6>,
+
+ /* Comment is not a blank line */
+ <7 8 9>;
+
+
+ interrupts = <1>;
+
+ /* Comment is not a blank line */
+ qcom,calibration-variant = "foo";
+ };
+
+
+ interrupt-controller@20000 {
+
+ compatible = "example,intc";
+ reg = <0x20000 0x1000>;
+
+ };
+};
diff --git a/scripts/dtc/dt-style-selftest/bad/yaml-blank-lines.yaml b/scripts/dtc/dt-style-selftest/bad/yaml-blank-lines.yaml
new file mode 100644
index 000000000000..a58cd534a003
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/bad/yaml-blank-lines.yaml
@@ -0,0 +1,54 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/test-bad-blank-lines.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Test fixture with too many blank lines
+
+maintainers:
+ - Test User <test@example.com>
+
+properties:
+ compatible:
+ const: example,test-blank-lines
+ reg:
+ maxItems: 1
+
+required:
+ - compatible
+ - reg
+
+additionalProperties: false
+
+examples:
+ - |
+ foo@1000 {
+ compatible = "example,test-blank-lines";
+
+ reg = <0x1000 0x100>;
+
+ clocks = <1 2 3>,
+
+
+ /* Comment is not a blank line */
+ <4 5 6>,
+
+ /* Comment is not a blank line */
+ <7 8 9>;
+
+
+ interrupts = <1>;
+
+ /* Comment is not a blank line */
+ qcom,calibration-variant = "foo";
+ };
+
+
+ foo@2000 {
+
+ compatible = "example,test-blank-lines";
+
+ reg = <0x2000 0x100>;
+
+ };
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-blank-lines.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-blank-lines.dts.txt
new file mode 100644
index 000000000000..97617bc42a17
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/dts-blank-lines.dts.txt
@@ -0,0 +1,6 @@
+# mode=strict
+bad/dts-blank-lines.dts:16: [blank-lines] consecutive blank lines
+bad/dts-blank-lines.dts:23: [blank-lines] consecutive blank lines
+bad/dts-blank-lines.dts:30: [blank-lines] consecutive blank lines
+bad/dts-blank-lines.dts:32: [blank-lines] blank line at start of node body
+bad/dts-blank-lines.dts:35: [blank-lines] blank line at end of node body
diff --git a/scripts/dtc/dt-style-selftest/expected/yaml-blank-lines.yaml.txt b/scripts/dtc/dt-style-selftest/expected/yaml-blank-lines.yaml.txt
new file mode 100644
index 000000000000..8a8db8d35b1e
--- /dev/null
+++ b/scripts/dtc/dt-style-selftest/expected/yaml-blank-lines.yaml.txt
@@ -0,0 +1,6 @@
+# mode=strict
+bad/yaml-blank-lines.yaml:33: example 0 [blank-lines] consecutive blank lines
+bad/yaml-blank-lines.yaml:40: example 0 [blank-lines] consecutive blank lines
+bad/yaml-blank-lines.yaml:47: example 0 [blank-lines] consecutive blank lines
+bad/yaml-blank-lines.yaml:49: example 0 [blank-lines] blank line at start of node body
+bad/yaml-blank-lines.yaml:53: example 0 [blank-lines] blank line at end of node body