Commit 869ae2b
devicetree.h: add DT_NODE_CHILD_IDX
It can be useful to know what a node's index is in its parent's list
of children. This information is now available to C via
gen_defines.py, but no user-facing macros are available to access it.
Add a macro which exposes this information to users via devicetree.h.
Some APIs want to build on devicetree.h by creating some derived
structure for each of a node's children. It can therefore be
convenient to use each child's index in the list of children as an
identifier for the child.
Some concrete and common examples are "gpio-keys" and "gpio-leds",
which allow you to define arbitrary numbers of keys and LEDs as child
nodes of nodes with those compatibles. Derived APIs can use a key or
LED node's index in its list of parents as a way to identify which of
several structures is relevant to a particular controlled key or LED.
These are just examples, though -- the feature added here makes no
assumptions about where it's being used.
Signed-off-by: Martí Bolívar <[email protected]>1 parent 50f9b3c commit 869ae2b
2 files changed
+32
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
477 | 501 | | |
478 | 502 | | |
479 | 503 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1996 | 1996 | | |
1997 | 1997 | | |
1998 | 1998 | | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
1999 | 2006 | | |
2000 | 2007 | | |
2001 | 2008 | | |
| |||
2369 | 2376 | | |
2370 | 2377 | | |
2371 | 2378 | | |
| 2379 | + | |
2372 | 2380 | | |
2373 | 2381 | | |
2374 | 2382 | | |
| |||
0 commit comments