Re: [PATCH] docs: dt-bindings: add DTS Coding Style document

From: Geert Uytterhoeven
Date: Thu Nov 16 2023 - 16:32:55 EST


Hi Krzysztof,

On Thu, Nov 16, 2023 at 7:12 PM Krzysztof Kozlowski
<krzysztof.kozlowski@xxxxxxxxxx> wrote>
> Document preferred coding style for Devicetree sources (DTS and DTSI),
> to bring consistency among all (sub)architectures and ease in reviews.

> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxx>

Thanks for your patch!

> --- a/Documentation/devicetree/bindings/index.rst
> +++ b/Documentation/devicetree/bindings/index.rst

> +Order of Nodes
> +--------------
> +
> +1. Nodes within any bus, thus using unit addresses for children, shall be
> + ordered incrementally by unit address.

In Renesas DTS files, we have an (unwritten) additional rule: when there
are multiple nodes of the same type, they do not follow the global
ordering by unit-address, but are grouped together.
E.g. the second and any subsequent serial ports are always listed
immediately after the first serial port.

> +2. Nodes without unit addresses should be ordered alpha-numerically.
> +
> +3. When extending nodes in board DTS via &label, the entries should be ordered
> + alpha-numerically.


> +Order of Properties in Device Node
> +----------------------------------
> +
> +Following order of properties in device nodes is preferred:
> +
> +1. compatible
> +2. reg
> +3. ranges
> +4. All properties with values
> +5. Boolean properties
> +6. status (if applicable)

There must be a lank line between properties and child nodes?

And once we have a documented coding style, the next long-standing item
from our wishlist would be a script to sort the contents of a DTS file
according to the rules ;-)

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds