dts: Add _OR variant macro for DT_PROP_LEN

Like DT_PROP_LEN_OR(), but with a fallback to
default_value.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2021-01-06 11:01:07 -08:00 committed by Anas Nashif
commit 12af01a121

View file

@ -442,6 +442,24 @@
*/
#define DT_PROP_LEN(node_id, prop) DT_PROP(node_id, prop##_LEN)
/**
* @brief Like DT_PROP_LEN(), but with a fallback to default_value
*
* If the property is defined (as determined by DT_NODE_HAS_PROP()),
* this expands to DT_PROP_LEN(node_id, prop). The default_value
* parameter is not expanded in this case.
*
* Otherwise, this expands to default_value.
*
* @param node_id node identifier
* @param prop a lowercase-and-underscores property with a logical length
* @param default_value a fallback value to expand to
* @return the property's length or the given default value
*/
#define DT_PROP_LEN_OR(node_id, prop, default_value) \
COND_CODE_1(DT_NODE_HAS_PROP(node_id, prop), \
(DT_PROP_LEN(node_id, prop)), (default_value))
/**
* @brief Is index "idx" valid for an array type property?
*