mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
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>
This commit is contained in:
parent
d5eefb1d97
commit
117d30d310
|
|
@ -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:
|
||||
|
|
|
|||
37
scripts/dtc/dt-style-selftest/bad/dts-blank-lines.dts
Normal file
37
scripts/dtc/dt-style-selftest/bad/dts-blank-lines.dts
Normal file
|
|
@ -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>;
|
||||
|
||||
};
|
||||
};
|
||||
54
scripts/dtc/dt-style-selftest/bad/yaml-blank-lines.yaml
Normal file
54
scripts/dtc/dt-style-selftest/bad/yaml-blank-lines.yaml
Normal file
|
|
@ -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>;
|
||||
|
||||
};
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
Loading…
Reference in New Issue
Block a user