dtc: dt-check-style: Add more DTS test cases
authorKrzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Thu, 9 Jul 2026 17:41:35 +0000 (19:41 +0200)
committerRob Herring (Arm) <robh@kernel.org>
Mon, 20 Jul 2026 20:50:57 +0000 (15:50 -0500)
Add a few more test cases for valid and incorrect DTS for
dt-check-style.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Link: https://patch.msgid.link/20260709-dts-style-checker-v5-7-fcc147cb697d@oss.qualcomm.com
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
scripts/dtc/dt-style-selftest/bad/dts-child-name-order.dts [new file with mode: 0644]
scripts/dtc/dt-style-selftest/bad/dts-extend-node-child-name-order.dts [new file with mode: 0644]
scripts/dtc/dt-style-selftest/bad/dts-extend-node-digit-node-order.dts [new file with mode: 0644]
scripts/dtc/dt-style-selftest/expected/dts-child-name-order.dts.txt [new file with mode: 0644]
scripts/dtc/dt-style-selftest/expected/dts-extend-node-child-name-order.dts.txt [new file with mode: 0644]
scripts/dtc/dt-style-selftest/expected/dts-extend-node-digit-node-order.dts.txt [new file with mode: 0644]
scripts/dtc/dt-style-selftest/good/dts-child-name-order.dts [new file with mode: 0644]
scripts/dtc/dt-style-selftest/good/dts-digit-node-order.dts [new file with mode: 0644]
scripts/dtc/dt-style-selftest/good/dts-extend-node-child-name-order.dts [new file with mode: 0644]
scripts/dtc/dt-style-selftest/good/dts-extend-node-digit-node-order.dts [new file with mode: 0644]

diff --git a/scripts/dtc/dt-style-selftest/bad/dts-child-name-order.dts b/scripts/dtc/dt-style-selftest/bad/dts-child-name-order.dts
new file mode 100644 (file)
index 0000000..49c5c10
--- /dev/null
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/ {
+       #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-extend-node-child-name-order.dts b/scripts/dtc/dt-style-selftest/bad/dts-extend-node-child-name-order.dts
new file mode 100644 (file)
index 0000000..575dadd
--- /dev/null
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/ {
+       #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.dts b/scripts/dtc/dt-style-selftest/bad/dts-extend-node-digit-node-order.dts
new file mode 100644 (file)
index 0000000..f3ffc47
--- /dev/null
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/ {
+       #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/expected/dts-child-name-order.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-child-name-order.dts.txt
new file mode 100644 (file)
index 0000000..86b1de9
--- /dev/null
@@ -0,0 +1,2 @@
+# mode=strict
+bad/dts-child-name-order.dts:14: [child-name-order] child node 'bar' out of name order
diff --git a/scripts/dtc/dt-style-selftest/expected/dts-extend-node-child-name-order.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-extend-node-child-name-order.dts.txt
new file mode 100644 (file)
index 0000000..e3d8fd3
--- /dev/null
@@ -0,0 +1,2 @@
+# mode=strict
+bad/dts-extend-node-child-name-order.dts:20: [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.dts.txt b/scripts/dtc/dt-style-selftest/expected/dts-extend-node-digit-node-order.dts.txt
new file mode 100644 (file)
index 0000000..5250818
--- /dev/null
@@ -0,0 +1,2 @@
+# mode=strict
+bad/dts-extend-node-digit-node-order.dts:21: [child-address-order] child node @10000 out of address order
diff --git a/scripts/dtc/dt-style-selftest/good/dts-child-name-order.dts b/scripts/dtc/dt-style-selftest/good/dts-child-name-order.dts
new file mode 100644 (file)
index 0000000..d2a2787
--- /dev/null
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/ {
+       #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>;
+       };
+};
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
new file mode 100644 (file)
index 0000000..d2bf586
--- /dev/null
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/ {
+       #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";
+       };
+
+       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>;
+               };
+       };
+};
diff --git a/scripts/dtc/dt-style-selftest/good/dts-extend-node-child-name-order.dts b/scripts/dtc/dt-style-selftest/good/dts-extend-node-child-name-order.dts
new file mode 100644 (file)
index 0000000..47fe545
--- /dev/null
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/ {
+       #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.dts b/scripts/dtc/dt-style-selftest/good/dts-extend-node-digit-node-order.dts
new file mode 100644 (file)
index 0000000..0c292fe
--- /dev/null
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/ {
+       #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>;
+       };
+};