devicetree: shorten DT_ANY_INST_HAS_*_STATUS_OKAY

shorten DT_ANY_INST_HAS_*_STATUS_OKAY macros

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
This commit is contained in:
Fin Maaß 2025-04-10 14:55:02 +02:00 committed by Benjamin Cabé
commit ca6645d508

View file

@ -4817,8 +4817,9 @@
* DT_ANY_INST_HAS_PROP_STATUS_OKAY(baz) // 0
* @endcode
*/
#define DT_ANY_INST_HAS_PROP_STATUS_OKAY(prop) \
COND_CODE_1(IS_EMPTY(DT_ANY_INST_HAS_PROP_STATUS_OKAY_(prop)), (0), (1))
#define DT_ANY_INST_HAS_PROP_STATUS_OKAY(prop) \
UTIL_NOT(IS_EMPTY( \
DT_INST_FOREACH_STATUS_OKAY_VARGS(DT_ANY_INST_HAS_PROP_STATUS_OKAY_, prop)))
/**
* @brief Check if any device node with status `okay` has a given
@ -4914,8 +4915,9 @@
* DT_ANY_INST_HAS_BOOL_STATUS_OKAY(baz) // 0
* @endcode
*/
#define DT_ANY_INST_HAS_BOOL_STATUS_OKAY(prop) \
COND_CODE_1(IS_EMPTY(DT_ANY_INST_HAS_BOOL_STATUS_OKAY_(prop)), (0), (1))
#define DT_ANY_INST_HAS_BOOL_STATUS_OKAY(prop) \
UTIL_NOT(IS_EMPTY( \
DT_INST_FOREACH_STATUS_OKAY_VARGS(DT_ANY_INST_HAS_BOOL_STATUS_OKAY_, prop)))
/**
* @brief Call @p fn on all nodes with compatible `DT_DRV_COMPAT`
@ -5186,7 +5188,7 @@
/** @cond INTERNAL_HIDDEN */
/** @brief Helper for DT_ANY_INST_HAS_PROP_STATUS_OKAY_
/** @brief Helper for DT_ANY_INST_HAS_PROP_STATUS_OKAY
*
* This macro generates token "1," for instance of a device,
* identified by index @p idx, if instance has property @p prop.
@ -5197,24 +5199,10 @@
* @return Macro evaluates to `1,` if instance has the property,
* otherwise it evaluates to literal nothing.
*/
#define DT_ANY_INST_HAS_PROP_STATUS_OKAY__(idx, prop) \
COND_CODE_1(DT_INST_NODE_HAS_PROP(idx, prop), (1,), ())
/** @brief Helper for DT_ANY_INST_HAS_PROP_STATUS_OKAY
*
* This macro uses DT_ANY_INST_HAS_PROP_STATUS_OKAY_ with
* DT_INST_FOREACH_STATUS_OKAY_VARG to generate comma separated list of 1,
* where each 1 on the list represents instance that has a property
* @p prop; the list may be empty, and the upper bound on number of
* list elements is number of device instances.
*
* @param prop property to check
*
* @return Evaluates to list of 1s (e.g: 1,1,1,) or nothing.
*/
#define DT_ANY_INST_HAS_PROP_STATUS_OKAY_(prop) \
DT_INST_FOREACH_STATUS_OKAY_VARGS(DT_ANY_INST_HAS_PROP_STATUS_OKAY__, prop)
#define DT_ANY_INST_HAS_PROP_STATUS_OKAY_(idx, prop) \
IF_ENABLED(DT_INST_NODE_HAS_PROP(idx, prop), (1,))
/** @brief Helper for DT_ANY_INST_HAS_BOOL_STATUS_OKAY_
/** @brief Helper for DT_ANY_INST_HAS_BOOL_STATUS_OKAY
*
* This macro generates token "1," for instance of a device,
* identified by index @p idx, if instance has boolean property
@ -5226,22 +5214,8 @@
* @return Macro evaluates to `1,` if instance property value is 1,
* otherwise it evaluates to literal nothing.
*/
#define DT_ANY_INST_HAS_BOOL_STATUS_OKAY__(idx, prop) \
COND_CODE_1(DT_INST_PROP(idx, prop), (1,), ())
/** @brief Helper for DT_ANY_INST_HAS_BOOL_STATUS_OKAY
*
* This macro uses DT_ANY_INST_HAS_BOOL_STATUS_OKAY_ with
* DT_INST_FOREACH_STATUS_OKAY_VARG to generate comma separated list of 1,
* where each 1 on the list represents instance that has a property
* @p prop of value 1; the list may be empty, and the upper bound on number of
* list elements is number of device instances.
*
* @param prop property to check
*
* @return Evaluates to list of 1s (e.g: 1,1,1,) or nothing.
*/
#define DT_ANY_INST_HAS_BOOL_STATUS_OKAY_(prop) \
DT_INST_FOREACH_STATUS_OKAY_VARGS(DT_ANY_INST_HAS_BOOL_STATUS_OKAY__, prop)
#define DT_ANY_INST_HAS_BOOL_STATUS_OKAY_(idx, prop) \
IF_ENABLED(DT_INST_PROP(idx, prop), (1,))
#define DT_PATH_INTERNAL(...) \
UTIL_CAT(DT_ROOT, MACRO_MAP_CAT(DT_S_PREFIX, __VA_ARGS__))