devicetree: add instance based macros for DT_ENUM_IDX(_OR)
The DT_ENUM_IDX and DT_ENUM_IDX_OR macros did not have the instance based equivalents. With them many drivers can be simplified. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
9ee28afe9f
commit
e425168b7c
1 changed files with 20 additions and 0 deletions
|
@ -2456,6 +2456,26 @@
|
|||
#define DT_INST_FOREACH_CHILD_VARGS(inst, fn, ...) \
|
||||
DT_FOREACH_CHILD_VARGS(DT_DRV_INST(inst), fn, __VA_ARGS__)
|
||||
|
||||
/**
|
||||
* @brief Get a DT_DRV_COMPAT value's index into its enumeration values
|
||||
* @param inst instance number
|
||||
* @param prop lowercase-and-underscores property name
|
||||
* @return zero-based index of the property's value in its enum: list
|
||||
*/
|
||||
#define DT_INST_ENUM_IDX(inst, prop) \
|
||||
DT_ENUM_IDX(DT_DRV_INST(inst), prop)
|
||||
|
||||
/**
|
||||
* @brief Like DT_INST_ENUM_IDX(), but with a fallback to a default enum index
|
||||
* @param inst instance number
|
||||
* @param prop lowercase-and-underscores property name
|
||||
* @param default_idx_value a fallback index value to expand to
|
||||
* @return zero-based index of the property's value in its enum if present,
|
||||
* default_idx_value ohterwise
|
||||
*/
|
||||
#define DT_INST_ENUM_IDX_OR(inst, prop, default_idx_value) \
|
||||
DT_ENUM_IDX_OR(DT_DRV_INST(inst), prop, default_idx_value)
|
||||
|
||||
/**
|
||||
* @brief Get a DT_DRV_COMPAT instance property
|
||||
* @param inst instance number
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue