devicetree: add new for-each macros
Add two new for-each macros:
- DT_FOREACH_STATUS_OKAY(compat, fn)
- DT_FOREACH_STATUS_OKAY_VARGS(compat, fn, ...)
These can be used to expand "fn" once for every status "okay" node in
the devicetree which has a given compatible. The intended use case is
to allow doing something in C once for each node of a compatible,
but outside of a device driver.
E.g. an application might want to collect an array of structures for a
compatible, where each structure is initialized from a node.
In such cases we don't want people to be forced into using
DT_DRV_COMPAT and instance numbers, because that's in general a hint
that you're doing something driver-like.
Signed-off-by:
Martí Bolívar <marti.bolivar@nordicsemi.no>
Loading
Please sign in to comment