mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
dtc: dt-check-style: Handle properly DTC-style includes
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>
This commit is contained in:
parent
597233e298
commit
29a91b7593
|
|
@ -49,6 +49,9 @@ re_cpp_directive = re.compile(
|
|||
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
|
||||
|
|
@ -66,7 +69,11 @@ re_ref_node = re.compile(
|
|||
|
||||
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:
|
||||
|
|
@ -178,7 +185,7 @@ def classify_lines(text):
|
|||
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
|
||||
|
|
|
|||
21
scripts/dtc/dt-style-selftest/good/dts-dtc.dts
Normal file
21
scripts/dtc/dt-style-selftest/good/dts-dtc.dts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// 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";
|
||||
};
|
||||
};
|
||||
};
|
||||
21
scripts/dtc/dt-style-selftest/good/dts-preprocessor.dts
Normal file
21
scripts/dtc/dt-style-selftest/good/dts-preprocessor.dts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// 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";
|
||||
};
|
||||
};
|
||||
};
|
||||
47
scripts/dtc/dt-style-selftest/good/soc.dtsi
Normal file
47
scripts/dtc/dt-style-selftest/good/soc.dtsi
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
// 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>;
|
||||
};
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user