lkml.org 
[lkml]   [2023]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] docs: dt-bindings: add DTS Coding Style document
From
On 16/11/2023 22:32, Geert Uytterhoeven wrote:
> Hi Krzysztof,
>
> On Thu, Nov 16, 2023 at 7:12 PM Krzysztof Kozlowski
> <krzysztof.kozlowski@linaro.org> 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@linaro.org>
>
> 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.

OK, I'll add here some exception paragraph. pin-state nodes also need one.

>
>> +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?

+1

>
> 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 ;-)

Yeah...

Best regards,
Krzysztof

\
 
 \ /
  Last update: 2023-11-20 14:05    [W:0.072 / U:1.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site