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:
Krzysztof Kozlowski 2026-09-11 13:42:05 +02:00 committed by Rob Herring (Arm)
parent d5eefb1d97
commit 117d30d310
5 changed files with 109 additions and 0 deletions

View File

@ -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:

View 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>;
};
};

View 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>;
};

View File

@ -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

View File

@ -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