public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] dt-bindings: automated coding style check for DTS examples
@ 2026-04-20 15:50 Daniel Golle
  2026-04-20 15:50 ` [PATCH 1/2] dt-bindings: add DTS example style checker Daniel Golle
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Daniel Golle @ 2026-04-20 15:50 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Saravana Kannan,
	Daniel Golle, devicetree, linux-kernel

Reviewing DTS examples in binding YAML files for coding style is
tedious and repetitive. The rules in dts-coding-style.rst are well
defined but currently not enforced by any tooling -- dtc does not
care about whitespace, and yamllint only sees the YAML structure,
not the DTS content inside literal block scalars.

This series adds a Python script that produces a canonical form of
each DTS example and diffs it against the original. Any difference
is a style violation. The checks cover:

 - 4-space indentation per nesting level
 - property ordering (compatible, reg, ranges, standard, vendor, status)
 - child node ordering by unit address
 - blank line placement (before child nodes and status, nowhere else)
 - no trailing whitespace, no tabs in DTS lines
 - node names using only [a-z0-9-]
 - no unused labels (defined but never &-referenced)

The script uses only ruamel.yaml (already required by dtschema) and
has no other dependencies. It is wired into dt_binding_check_one
with || true, so currently informational.

Running it against the current tree finds issues in roughly 70% of
existing binding files -- mostly indentation (many older bindings
use 2-space indent) and unused labels. These can be cleaned up in
follow-up series; the immediate value is catching problems in new
submissions before reviewers have to.

A --diff flag produces unified diffs showing exactly what needs to
change, making fixes trivial. A future --fix mode could rewrite
examples in-place.

As someone who has repeatedly annoyed DT maintainers with exactly
the kind of mistakes this tool catches, I hope this makes up for
some of that. And since my Python is even much worse than my DTS
coding style, the script was written with generous help from
Claude Opus 4.6.

Daniel Golle (2):
  dt-bindings: add DTS example style checker
  dt-bindings: wire example style check into dt_binding_check

 Documentation/devicetree/bindings/Makefile |  15 +-
 scripts/dtc/dt-check-example-style         | 712 +++++++++++++++++++++
 2 files changed, 725 insertions(+), 2 deletions(-)
 create mode 100755 scripts/dtc/dt-check-example-style

-- 
2.53.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-20 21:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-20 15:50 [PATCH 0/2] dt-bindings: automated coding style check for DTS examples Daniel Golle
2026-04-20 15:50 ` [PATCH 1/2] dt-bindings: add DTS example style checker Daniel Golle
2026-04-20 15:50 ` [PATCH 2/2] dt-bindings: wire example style check into dt_binding_check Daniel Golle
2026-04-20 21:51 ` [PATCH 0/2] dt-bindings: automated coding style check for DTS examples Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox