Skip to content

Commit 6c269a9

Browse files
committed
doc: contribute: Add multiline property style guide
Add guidelines for how to split long property values across multiple lines. This documents the style that is enforced by the devicetree linter. Link: zephyrproject-rtos#92334 Signed-off-by: Keith Short <keithshort@google.com>
1 parent f52d71c commit 6c269a9

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

doc/contribute/style/devicetree.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,13 @@ Devicetree Style Guidelines
1717
definitions.
1818
* Don't insert empty lines before a dedenting ``};``.
1919
* Insert a single empty line to separate nodes at the same hierarchy level.
20+
* When splitting long property values across multiple lines, specify the first
21+
value on the same line as the opening bracket (``<`` or ``[``). Place the
22+
closing bracket and semicolon (``>;`` or ``];``) on the same line after
23+
the final value of the property.
24+
25+
Examples:
26+
27+
.. literalinclude:: style-example.dts
28+
:language: devicetree
29+
:start-after: start-after-here
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* SPDX-FileCopyrightText: Copyright The Zephyr Project Contributors
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Demonstration of permitted and disallowed coding style for devicetree files.
7+
*/
8+
9+
/* start-after-here */
10+
11+
/dts-v1/;
12+
13+
/ {
14+
/* Node labels use the "_" separator, but node names use "-". */
15+
psa_rng: psa-rng {
16+
compatible = "zephyr,psa-crypto-rng";
17+
status = "okay";
18+
};
19+
20+
ramdisk0 {
21+
compatible = "zephyr,ram-disk";
22+
/* Property names use the "-" separator. */
23+
disk-name = "RAM";
24+
sector-size = <512>;
25+
sector-count = <128>;
26+
};
27+
28+
periph0 {
29+
/* Wrap array values to conform with line lengths. Indent
30+
* continuation so that values align.
31+
*/
32+
pinctrl-0 = <&periph0_siga_px0_default &periph0_sigb_py7_default
33+
&periph0_sigc_pz1_default>;
34+
pinctrl-names = "default";
35+
};
36+
37+
mipi-dbi {
38+
compatible = "zephyr,mipi-dbi-spi";
39+
40+
lcd0: lcd@0 {
41+
compatible = "sitronix,st7735r";
42+
/* Split array values across multiple lines to help readability. */
43+
gamctrp1 = [10 0E 02 03
44+
0E 07 02 07
45+
0A 12 27 37
46+
00 0D 0E 10];
47+
gamctrn1 = [10 0E 03 03
48+
0F 06 02 08
49+
0A 13 26 36
50+
00 0D 0E 10];
51+
};
52+
};
53+
};

0 commit comments

Comments
 (0)