From: Daniel Golle <daniel@makrotopia.org>
To: "Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nicolas Schier" <nsc@kernel.org>,
"Saravana Kannan" <saravanak@kernel.org>,
"Daniel Golle" <daniel@makrotopia.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Masahiro Yamada" <masahiroy@kernel.org>,
"Thomas Weißschuh" <linux@weissschuh.net>,
"Tamir Duberstein" <tamird@kernel.org>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Guenter Roeck" <linux@roeck-us.net>,
"Aleksander Jan Bajkowski" <olek2@wp.pl>,
"Test User" <test@example.com>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kbuild@vger.kernel.org
Subject: [PATCH v2 0/3] dt-bindings: automated coding style check for DTS examples
Date: Wed, 29 Apr 2026 15:21:16 +0100 [thread overview]
Message-ID: <cover.1777471439.git.daniel@makrotopia.org> (raw)
v1: https://lore.kernel.org/all/cover.1776700167.git.daniel@makrotopia.org/
Following v1 review feedback, this series replaces the original
single-mode checker with one organised around a declarative rule
registry. Each rule is tagged 'relaxed' (default; must be
zero-violation on the current tree) or 'strict' (opt-in for new
submissions); promoting a rule from strict to relaxed is a one-line
edit once the tree catches up.
Default mode runs cleanly on the current tree once the small prep
series [1] has landed. Stricter rules (indent unit, property
ordering, blank-line placement, sibling address ordering, unused
labels, line length, value rendering, ...) live behind --mode=strict
and are intended for use by checkpatch.pl in a follow-up series.
The tool also accepts .dts/.dtsi/.dtso files directly (with a
tab-indent rule) so it can be reused for actual device tree sources.
It reads file paths from @argfile and parallelises across CPUs, with
$PARALLELISM (set by scripts/jobserver-exec) honoured so the worker
count tracks `make -j N`. ruamel.yaml is the only non-stdlib
dependency, already required by dtschema.
In aggregate, strict mode pins down indentation, blank lines,
property and child ordering, hex casing, unit-address format,
whitespace inside <...>, line length (80 cols), continuation
alignment, closing brace placement and unused labels -- enough to
drive a single canonical layout per DT structure modulo the
author's choice of when to wrap properties for readability.
Strict-mode violation counts on a current tree (5506 YAML bindings,
6530 in-tree .dts/.dtsi/.dtso under arch/):
rule yaml dts
property-order 14457 240804
indent-consistent 2435 294778
continuation-alignment 2462 187914
unused-labels 3611 11628
required-blank-lines 1862 47351
line-length 102 25999
child-name-order 664 16409
mixed-indent-chars 0 13275
indent-unit-strict 1493 --
child-address-order 69 4075
blank-lines 91 1963
value-whitespace 87 983
node-close-alone 40 783
hex-case 78 666
indent-unit 181 --
indent-unit-dts -- 202
unit-address-format 5 39
trailing-whitespace 0 10
(YAML and DTS columns reflect the rules that apply to each input
type; e.g. indent-unit-strict is YAML-only since .dts files use
tabs, indent-unit-dts is the equivalent DTS-only check.
unused-labels is skipped for .dtsi/.dtso since labels there are
exported to includers/applies-to.)
The script was written with generous help from Claude Opus 4.7,
since my Python is even worse than my DTS coding style.
[1] https://lore.kernel.org/all/cover.1777434096.git.daniel@makrotopia.org/
Daniel Golle (3):
dt-bindings: add DTS style checker
dt-bindings: wire style checker into dt_binding_check
dt-bindings: add self-test fixtures for style checker
Documentation/devicetree/bindings/Makefile | 20 +-
Makefile | 6 +
scripts/dtc/dt-check-style | 1063 +++++++++++++++++
.../dtc/dt-style-selftest/bad/dts-spaces.dts | 13 +
.../bad/yaml-child-addr-order.yaml | 41 +
.../bad/yaml-child-name-order.yaml | 37 +
.../bad/yaml-cont-align.yaml | 30 +
.../dt-style-selftest/bad/yaml-hex-case.yaml | 29 +
.../bad/yaml-indent-strict.yaml | 29 +
.../bad/yaml-line-length.yaml | 29 +
.../bad/yaml-mixed-indent.yaml | 29 +
.../bad/yaml-node-close.yaml | 31 +
.../bad/yaml-prop-order.yaml | 29 +
.../bad/yaml-prop-pairing.yaml | 33 +
.../bad/yaml-required-blank.yaml | 33 +
.../dtc/dt-style-selftest/bad/yaml-tab.yaml | 29 +
.../bad/yaml-trailing-ws.yaml | 29 +
.../dt-style-selftest/bad/yaml-unit-addr.yaml | 29 +
.../bad/yaml-unused-label.yaml | 29 +
.../dt-style-selftest/bad/yaml-value-ws.yaml | 29 +
.../expected/dts-spaces.dts.txt | 2 +
.../expected/yaml-child-addr-order.yaml.txt | 2 +
.../expected/yaml-child-name-order.yaml.txt | 2 +
.../expected/yaml-cont-align.yaml.txt | 2 +
.../expected/yaml-hex-case.yaml.txt | 2 +
.../expected/yaml-indent-strict.yaml.txt | 2 +
.../expected/yaml-line-length.yaml.txt | 2 +
.../expected/yaml-mixed-indent.yaml.txt | 3 +
.../expected/yaml-node-close.yaml.txt | 2 +
.../expected/yaml-prop-order.yaml.txt | 2 +
.../expected/yaml-prop-pairing.yaml.txt | 3 +
.../expected/yaml-required-blank.yaml.txt | 3 +
.../expected/yaml-tab.yaml.txt | 2 +
.../expected/yaml-trailing-ws.yaml.txt | 2 +
.../expected/yaml-unit-addr.yaml.txt | 2 +
.../expected/yaml-unused-label.yaml.txt | 2 +
.../expected/yaml-value-ws.yaml.txt | 2 +
.../dtc/dt-style-selftest/good/dts-tab.dts | 30 +
.../dt-style-selftest/good/yaml-4space.yaml | 41 +
scripts/dtc/dt-style-selftest/run.sh | 67 ++
40 files changed, 1770 insertions(+), 2 deletions(-)
create mode 100755 scripts/dtc/dt-check-style
create mode 100644 scripts/dtc/dt-style-selftest/bad/dts-spaces.dts
create mode 100644 scripts/dtc/dt-style-selftest/bad/yaml-child-addr-order.yaml
create mode 100644 scripts/dtc/dt-style-selftest/bad/yaml-child-name-order.yaml
create mode 100644 scripts/dtc/dt-style-selftest/bad/yaml-cont-align.yaml
create mode 100644 scripts/dtc/dt-style-selftest/bad/yaml-hex-case.yaml
create mode 100644 scripts/dtc/dt-style-selftest/bad/yaml-indent-strict.yaml
create mode 100644 scripts/dtc/dt-style-selftest/bad/yaml-line-length.yaml
create mode 100644 scripts/dtc/dt-style-selftest/bad/yaml-mixed-indent.yaml
create mode 100644 scripts/dtc/dt-style-selftest/bad/yaml-node-close.yaml
create mode 100644 scripts/dtc/dt-style-selftest/bad/yaml-prop-order.yaml
create mode 100644 scripts/dtc/dt-style-selftest/bad/yaml-prop-pairing.yaml
create mode 100644 scripts/dtc/dt-style-selftest/bad/yaml-required-blank.yaml
create mode 100644 scripts/dtc/dt-style-selftest/bad/yaml-tab.yaml
create mode 100644 scripts/dtc/dt-style-selftest/bad/yaml-trailing-ws.yaml
create mode 100644 scripts/dtc/dt-style-selftest/bad/yaml-unit-addr.yaml
create mode 100644 scripts/dtc/dt-style-selftest/bad/yaml-unused-label.yaml
create mode 100644 scripts/dtc/dt-style-selftest/bad/yaml-value-ws.yaml
create mode 100644 scripts/dtc/dt-style-selftest/expected/dts-spaces.dts.txt
create mode 100644 scripts/dtc/dt-style-selftest/expected/yaml-child-addr-order.yaml.txt
create mode 100644 scripts/dtc/dt-style-selftest/expected/yaml-child-name-order.yaml.txt
create mode 100644 scripts/dtc/dt-style-selftest/expected/yaml-cont-align.yaml.txt
create mode 100644 scripts/dtc/dt-style-selftest/expected/yaml-hex-case.yaml.txt
create mode 100644 scripts/dtc/dt-style-selftest/expected/yaml-indent-strict.yaml.txt
create mode 100644 scripts/dtc/dt-style-selftest/expected/yaml-line-length.yaml.txt
create mode 100644 scripts/dtc/dt-style-selftest/expected/yaml-mixed-indent.yaml.txt
create mode 100644 scripts/dtc/dt-style-selftest/expected/yaml-node-close.yaml.txt
create mode 100644 scripts/dtc/dt-style-selftest/expected/yaml-prop-order.yaml.txt
create mode 100644 scripts/dtc/dt-style-selftest/expected/yaml-prop-pairing.yaml.txt
create mode 100644 scripts/dtc/dt-style-selftest/expected/yaml-required-blank.yaml.txt
create mode 100644 scripts/dtc/dt-style-selftest/expected/yaml-tab.yaml.txt
create mode 100644 scripts/dtc/dt-style-selftest/expected/yaml-trailing-ws.yaml.txt
create mode 100644 scripts/dtc/dt-style-selftest/expected/yaml-unit-addr.yaml.txt
create mode 100644 scripts/dtc/dt-style-selftest/expected/yaml-unused-label.yaml.txt
create mode 100644 scripts/dtc/dt-style-selftest/expected/yaml-value-ws.yaml.txt
create mode 100644 scripts/dtc/dt-style-selftest/good/dts-tab.dts
create mode 100644 scripts/dtc/dt-style-selftest/good/yaml-4space.yaml
create mode 100755 scripts/dtc/dt-style-selftest/run.sh
--
2.54.0
next reply other threads:[~2026-04-29 14:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 14:21 Daniel Golle [this message]
2026-04-29 14:21 ` [PATCH v2 1/3] dt-bindings: add DTS style checker Daniel Golle
2026-04-29 14:21 ` [PATCH v2 2/3] dt-bindings: wire style checker into dt_binding_check Daniel Golle
2026-04-30 23:13 ` Nathan Chancellor
2026-04-29 14:21 ` [PATCH v2 3/3] dt-bindings: add self-test fixtures for style checker Daniel Golle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1777471439.git.daniel@makrotopia.org \
--to=daniel@makrotopia.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=linux@weissschuh.net \
--cc=masahiroy@kernel.org \
--cc=nathan@kernel.org \
--cc=nsc@kernel.org \
--cc=ojeda@kernel.org \
--cc=olek2@wp.pl \
--cc=robh@kernel.org \
--cc=rostedt@goodmis.org \
--cc=saravanak@kernel.org \
--cc=tamird@kernel.org \
--cc=test@example.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox