Skip to content

Commit ca6645d

Browse files
maass-hamburgkartben
authored andcommitted
devicetree: shorten DT_ANY_INST_HAS_*_STATUS_OKAY
shorten DT_ANY_INST_HAS_*_STATUS_OKAY macros Signed-off-by: Fin Maaß <[email protected]>
1 parent 07c1d95 commit ca6645d

File tree

1 file changed

+12
-38
lines changed

1 file changed

+12
-38
lines changed

include/zephyr/devicetree.h

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4817,8 +4817,9 @@
48174817
* DT_ANY_INST_HAS_PROP_STATUS_OKAY(baz) // 0
48184818
* @endcode
48194819
*/
4820-
#define DT_ANY_INST_HAS_PROP_STATUS_OKAY(prop) \
4821-
COND_CODE_1(IS_EMPTY(DT_ANY_INST_HAS_PROP_STATUS_OKAY_(prop)), (0), (1))
4820+
#define DT_ANY_INST_HAS_PROP_STATUS_OKAY(prop) \
4821+
UTIL_NOT(IS_EMPTY( \
4822+
DT_INST_FOREACH_STATUS_OKAY_VARGS(DT_ANY_INST_HAS_PROP_STATUS_OKAY_, prop)))
48224823

48234824
/**
48244825
* @brief Check if any device node with status `okay` has a given
@@ -4914,8 +4915,9 @@
49144915
* DT_ANY_INST_HAS_BOOL_STATUS_OKAY(baz) // 0
49154916
* @endcode
49164917
*/
4917-
#define DT_ANY_INST_HAS_BOOL_STATUS_OKAY(prop) \
4918-
COND_CODE_1(IS_EMPTY(DT_ANY_INST_HAS_BOOL_STATUS_OKAY_(prop)), (0), (1))
4918+
#define DT_ANY_INST_HAS_BOOL_STATUS_OKAY(prop) \
4919+
UTIL_NOT(IS_EMPTY( \
4920+
DT_INST_FOREACH_STATUS_OKAY_VARGS(DT_ANY_INST_HAS_BOOL_STATUS_OKAY_, prop)))
49194921

49204922
/**
49214923
* @brief Call @p fn on all nodes with compatible `DT_DRV_COMPAT`
@@ -5186,7 +5188,7 @@
51865188

51875189
/** @cond INTERNAL_HIDDEN */
51885190

5189-
/** @brief Helper for DT_ANY_INST_HAS_PROP_STATUS_OKAY_
5191+
/** @brief Helper for DT_ANY_INST_HAS_PROP_STATUS_OKAY
51905192
*
51915193
* This macro generates token "1," for instance of a device,
51925194
* identified by index @p idx, if instance has property @p prop.
@@ -5197,24 +5199,10 @@
51975199
* @return Macro evaluates to `1,` if instance has the property,
51985200
* otherwise it evaluates to literal nothing.
51995201
*/
5200-
#define DT_ANY_INST_HAS_PROP_STATUS_OKAY__(idx, prop) \
5201-
COND_CODE_1(DT_INST_NODE_HAS_PROP(idx, prop), (1,), ())
5202-
/** @brief Helper for DT_ANY_INST_HAS_PROP_STATUS_OKAY
5203-
*
5204-
* This macro uses DT_ANY_INST_HAS_PROP_STATUS_OKAY_ with
5205-
* DT_INST_FOREACH_STATUS_OKAY_VARG to generate comma separated list of 1,
5206-
* where each 1 on the list represents instance that has a property
5207-
* @p prop; the list may be empty, and the upper bound on number of
5208-
* list elements is number of device instances.
5209-
*
5210-
* @param prop property to check
5211-
*
5212-
* @return Evaluates to list of 1s (e.g: 1,1,1,) or nothing.
5213-
*/
5214-
#define DT_ANY_INST_HAS_PROP_STATUS_OKAY_(prop) \
5215-
DT_INST_FOREACH_STATUS_OKAY_VARGS(DT_ANY_INST_HAS_PROP_STATUS_OKAY__, prop)
5202+
#define DT_ANY_INST_HAS_PROP_STATUS_OKAY_(idx, prop) \
5203+
IF_ENABLED(DT_INST_NODE_HAS_PROP(idx, prop), (1,))
52165204

5217-
/** @brief Helper for DT_ANY_INST_HAS_BOOL_STATUS_OKAY_
5205+
/** @brief Helper for DT_ANY_INST_HAS_BOOL_STATUS_OKAY
52185206
*
52195207
* This macro generates token "1," for instance of a device,
52205208
* identified by index @p idx, if instance has boolean property
@@ -5226,22 +5214,8 @@
52265214
* @return Macro evaluates to `1,` if instance property value is 1,
52275215
* otherwise it evaluates to literal nothing.
52285216
*/
5229-
#define DT_ANY_INST_HAS_BOOL_STATUS_OKAY__(idx, prop) \
5230-
COND_CODE_1(DT_INST_PROP(idx, prop), (1,), ())
5231-
/** @brief Helper for DT_ANY_INST_HAS_BOOL_STATUS_OKAY
5232-
*
5233-
* This macro uses DT_ANY_INST_HAS_BOOL_STATUS_OKAY_ with
5234-
* DT_INST_FOREACH_STATUS_OKAY_VARG to generate comma separated list of 1,
5235-
* where each 1 on the list represents instance that has a property
5236-
* @p prop of value 1; the list may be empty, and the upper bound on number of
5237-
* list elements is number of device instances.
5238-
*
5239-
* @param prop property to check
5240-
*
5241-
* @return Evaluates to list of 1s (e.g: 1,1,1,) or nothing.
5242-
*/
5243-
#define DT_ANY_INST_HAS_BOOL_STATUS_OKAY_(prop) \
5244-
DT_INST_FOREACH_STATUS_OKAY_VARGS(DT_ANY_INST_HAS_BOOL_STATUS_OKAY__, prop)
5217+
#define DT_ANY_INST_HAS_BOOL_STATUS_OKAY_(idx, prop) \
5218+
IF_ENABLED(DT_INST_PROP(idx, prop), (1,))
52455219

52465220
#define DT_PATH_INTERNAL(...) \
52475221
UTIL_CAT(DT_ROOT, MACRO_MAP_CAT(DT_S_PREFIX, __VA_ARGS__))

0 commit comments

Comments
 (0)