Skip to content

Commit

Permalink
docs: dt: writing-schema: mention coding style
Browse files Browse the repository at this point in the history
Mention the usage of YAML coding style.  Describe explicitly that
four-space indentation in DTS examples is preferred, because:
1. The YAML's default two-space indentation for DTS code makes it
   significantly less readable.
2. Linux coding style tabs would introduce inconsistency (entire file is
   indented with spaces).
3. On the other hand, eight spaces would not align with example's
   opening '  - |' part.  Four spaces makes the code nicely aligned with
   it.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20220403081849.8051-2-krzysztof.kozlowski@linaro.org
  • Loading branch information
Krzysztof Kozlowski authored and Rob Herring committed Apr 5, 2022
1 parent 44c8a51 commit 7a150b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Documentation/devicetree/bindings/example-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,13 @@ examples:
# be overridden or an appropriate parent bus node should be shown (such as on
# i2c buses).
#
# Any includes used have to be explicitly included.
# Any includes used have to be explicitly included. Use 4-space indentation.
- |
node@1000 {
compatible = "vendor,soc4-ip", "vendor,soc1-ip";
reg = <0x1000 0x80>,
<0x3000 0x80>;
reg-names = "core", "aux";
interrupts = <10>;
interrupt-controller;
compatible = "vendor,soc4-ip", "vendor,soc1-ip";
reg = <0x1000 0x80>,
<0x3000 0x80>;
reg-names = "core", "aux";
interrupts = <10>;
interrupt-controller;
};
6 changes: 6 additions & 0 deletions Documentation/devicetree/bindings/writing-schema.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ The YAML Devicetree format also makes all string values an array and scalar
values a matrix (in order to define groupings) even when only a single value
is present. Single entries in schemas are fixed up to match this encoding.

Coding style
------------

Use YAML coding style (two-space indentation). For DTS examples in the schema,
preferred is four-space indentation.

Testing
-------

Expand Down

0 comments on commit 7a150b0

Please sign in to comment.