Skip to content

Commit 50f9b3c

Browse files
mbolivar-nordiccarlescufi
authored andcommitted
gen_defines: add _CHILD_IDX macros for nodes with parents
These expose every node's index in its parent's list of children to C. The root node has no parent, so no _CHILD_IDX macro is generated for it. Keep macros.bnf up to date with the new generated macros. Signed-off-by: Martí Bolívar <[email protected]>
1 parent 355cc01 commit 50f9b3c

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

doc/guides/dts/macros.bnf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ node-macro =/ %s"DT_N" path-id %s"_FOREACH_CHILD_VARGS"
6767
; over each child node with status "okay".
6868
node-macro =/ %s"DT_N" path-id %s"_FOREACH_CHILD_STATUS_OKAY"
6969
node-macro =/ %s"DT_N" path-id %s"_FOREACH_CHILD_STATUS_OKAY_VARGS"
70+
; The node's zero-based index in the list of it's parent's child nodes.
71+
node-macro =/ %s"DT_N" path-id %s"_CHILD_IDX"
7072
; The node's status macro; dt-name in this case is something like "okay"
7173
; or "disabled".
7274
node-macro =/ %s"DT_N" path-id %s"_STATUS_" dt-name

scripts/dts/gen_defines.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ def main():
132132
out_dt_define(f"{node.z_path_id}_PARENT",
133133
f"DT_{node.parent.z_path_id}")
134134

135+
out_comment(f"Node's index in its parent's list of children:")
136+
out_dt_define(f"{node.z_path_id}_CHILD_IDX",
137+
node.parent.child_index(node))
138+
135139
write_children(node)
136140
write_dep_info(node)
137141
write_idents_and_existence(node)

0 commit comments

Comments
 (0)