[PATCH v3] docs: dt-bindings: add DTS Coding Style document
Andrew Lunn
andrew at lunn.ch
Sun Nov 26 09:48:13 PST 2023
On Sun, Nov 26, 2023 at 11:38:38AM +0100, Krzysztof Kozlowski wrote:
> On 25/11/2023 20:47, Andrew Lunn wrote:
> >> +=====================================
> >> +Devicetree Sources (DTS) Coding Style
> >> +=====================================
> >> +
> >> +When writing Devicetree Sources (DTS) please observe below guidelines. They
> >> +should be considered complementary to any rules expressed already in Devicetree
> >> +Specification and dtc compiler (including W=1 and W=2 builds).
> >> +
> >> +Individual architectures and sub-architectures can add additional rules, making
> >> +the style stricter.
> >
> > It would be nice to add a pointer where such rules are documented.
>
> Subsystem profile or any other place. The generic doc should not point
> to specific ones.
That is not so friendly for a developer. A reviewer points out that a
file is not consistent with the coding style. So they go away and fix
it, as described here. They then get a second review which say, no,
you to do X, Y and Z, despite them actually following the coding
style.
Maybe add to the paragraph above:
These further restrictions are voluntary, until added to this
document.
This should encourage those architectures to document their coding
style.
> The root node is a bit special, but other than that mixing nodes with
> and without unit address is discouraged practice.
If the root node is special, maybe it needs a few rules of its own?
All properties without an address come first, then properties with
addresses. Sorting within these classes follow the normal rules
already stated?
> >> +Indentation
> >> +-----------
> >> +
> >> +1. Use indentation according to :ref:`codingstyle`.
> >> +2. For arrays spanning across lines, it is preferred to align the continued
> >> + entries with opening < from the first line.
> >> +3. Each entry in arrays with multiple cells (e.g. "reg" with two IO addresses)
> >> + shall be enclosed in <>.
> >> +
> >> +Example::
> >> +
> >> + thermal-sensor at c271000 {
> >> + compatible = "qcom,sm8550-tsens", "qcom,tsens-v2";
> >> + reg = <0x0 0x0c271000 0x0 0x1000>,
> >> + <0x0 0x0c222000 0x0 0x1000>;
> >> + };
> >
> > I'm not sure i understand this. Is this example correct?
> >
> > gpio-fan,speed-map = <0 0
> > 3000 1
> > 6000 2>;
> >
> > It exists a lot in todays files.
>
> Depends on the binidng. Is it matrix? If yes, then it is not correct.
It seems to me, rules 2 and 3 should be swapped. You can only align
the <, if you have <. So logically, the rule about having < should
come first.
Andrew
More information about the linux-amlogic
mailing list