dt-check-style was not properly handling DTC directives (starting with
'/', e.g. /dts-v1/ or /include/), thus a few DTS files had false
positive like:
apm/apm-merlin.dts:1: [indent-unit-dts] indent unit must be 1 tab in DTS, got '\t\t'
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Link: https://patch.msgid.link/20260709-dts-style-checker-v5-5-fcc147cb697d@oss.qualcomm.com
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
r'^#\s*(include|define|undef|ifdef|ifndef|if|else|elif|endif|'
r'pragma|error|warning)\b')
+re_dtc_directive = re.compile(
+ r'^/(dts-v1|include)/')
+
# label: name@addr { -- label and addr optional; name can be "/"
# Per the DT spec a node name may start with a digit (e.g. 1wire@...).
# The address part is captured loosely (any non-space, non-brace run) so
def is_preprocessor(stripped):
"""Tell C preprocessor directives apart from DTS '#'-prefixed props."""
- return re_cpp_directive.match(stripped) is not None
+ if re_cpp_directive.match(stripped) is not None:
+ return True
+ if re_dtc_directive.match(stripped) is not None:
+ return True
+ return False
class DtsLine:
out.append(dl)
continue
- if stripped.startswith('#') and is_preprocessor(stripped):
+ if (stripped.startswith('#') or stripped.startswith('/')) and is_preprocessor(stripped):
dl = DtsLine(i, raw, LineType.PREPROCESSOR,
indent_str, stripped)
dl.depth = depth
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/*
+ * Test fixture: dtc directive
+ */
+
+/dts-v1/;
+
+/include/ "soc.dtsi"
+/include/"soc-other.dtsi"
+
+/ {
+ compatible = "example,test-board";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ leds {
+ led-0 {
+ compatible = "example,led";
+ };
+ };
+};
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/*
+ * Test fixture: preprocessor directive
+ */
+
+/dts-v1/;
+
+#include "soc.dtsi"
+#include<dt-bindings/gpio/gpio.h>
+
+/ {
+ compatible = "example,test-board";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ leds {
+ led-0 {
+ compatible = "example,led";
+ };
+ };
+};
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ 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";
+ };
+
+ 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>,
+ <4 5 6>,
+ <7 8 9>;
+ };
+
+ serial@20000 {
+ compatible = "example,serial";
+ reg = <0x20000 0x1000>;
+ };
+
+ serial@30000 {
+ compatible = "example,serial";
+ reg = <0x30000 0x1000>;
+ };
+ };
+};