Skip to content

Commit d363781

Browse files
thedjnKcarlescufi
authored andcommitted
gpio: Fix GPIO_DT_SPEC_INST_GET_BY_IDX_OR macro
Fixes the macro for getting the instance of a device tree GPIO with index or default value. Signed-off-by: Jamie McCrae <[email protected]>
1 parent 73584df commit d363781

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

include/zephyr/drivers/gpio.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,10 @@ struct gpio_dt_spec {
388388
* @return static initializer for a struct gpio_dt_spec for the property
389389
* @see GPIO_DT_SPEC_GET_BY_IDX()
390390
*/
391-
#define GPIO_DT_SPEC_INST_GET_BY_IDX_OR(inst, prop, idx, default_value) \
392-
GPIO_DT_SPEC_GET_BY_IDX_OR(DT_DRV_INST(inst), prop, idx, default_value)
391+
#define GPIO_DT_SPEC_INST_GET_BY_IDX_OR(inst, prop, idx, default_value) \
392+
COND_CODE_1(DT_PROP_HAS_IDX(DT_DRV_INST(inst), prop, idx), \
393+
(GPIO_DT_SPEC_GET_BY_IDX(DT_DRV_INST(inst), prop, idx)), \
394+
(default_value))
393395

394396
/**
395397
* @brief Equivalent to GPIO_DT_SPEC_INST_GET_BY_IDX(inst, prop, 0).

0 commit comments

Comments
 (0)