文档版本:Linux Kernel 6.9.0-rc3
Devicetree Sources (DTS) Coding Style
在编写 Devicetree Sources (DTS) 时,请遵守以下准则。它们应被视为对 Devicetree 规范和 dtc 编译器(包括 W=1 和 W=2 版本)中已有规则的补充。
When writing Devicetree Sources (DTS) please observe below guidelines. They should be considered complementary to any rules expressed already in the Devicetree Specification and the dtc compiler (including W=1 and W=2 builds).
|
个别架构和子架构可以定义额外的规则,使编码风格更加严格。
Individual architectures and subarchitectures can define additional rules, making the coding style stricter.
|
Naming and Valid Characters [ 命名和有效字符 ]
《Devicetree 规范》允许在节点和属性名称中使用多种字符,但这种编码方式缩小了字符范围,以提高代码的可读性。
The Devicetree Specification allows a broad range of characters in node and property names, but this coding style narrows the range down to achieve better code readability.
|
1,节点和属性名称只能使用以下字符:
-
小写字母 [a-z]
-
数字: [0-9]
-
破折号: -
2,标签只能使用以下字符:
-
小写字符: [a-z]
-
数字: [0-9]
-
下划线: _
3,除非总线另有规定,否则单元地址应使用小写十六进制数字,不含前导零(填充)。
4,属性中的十六进制值,如 "reg",应使用小写十六进制。地址部分可以用前导零填充。
1. Node and property names can use only the following characters:
* Lowercase characters: [a-z]
* Digits: [0-9]
* Dash: -
2. Labels can use only the following characters:
* Lowercase characters: [a-z]
* Digits: [0-9]
* Underscore: _
3. Unless a bus defines differently, unit addresses shall use lowercase hexadecimal digits, without leading zeros (padding).
4. Hex values in properties, e.g. “reg”, shall use lowercase hex. The address part can be padded with leading zeros.
|
Example:
gpi_dma2: dma-controller@a00000 {
compatible = "qcom,sm8550-gpi-dma", "qcom,sm6350-gpi-dma";
&nb