drivers: led_pwm: fix device name fallback
If the label property is missing in a "pwm-leds" compatible DT node (which is almost always the case), then the device name is now set to DT_NODE_FULL_NAME instead of "LED_PWM_$inst" previously. This allows applications to use the DEVICE_DT_NAME macro to retrieve the device name instead of gessing an arbitrary string. Signed-off-by: Simon Guinot <simon.guinot@seagate.com>
This commit is contained in:
parent
79a3a0f40b
commit
df01148aeb
2 changed files with 5 additions and 9 deletions
|
@ -232,13 +232,9 @@ static const struct led_pwm_config led_pwm_config_##id = { \
|
|||
\
|
||||
static struct led_pwm_data led_pwm_data_##id; \
|
||||
\
|
||||
DEVICE_DEFINE(led_pwm_##id, \
|
||||
DT_INST_PROP_OR(id, label, "LED_PWM_"#id), \
|
||||
&led_pwm_init, \
|
||||
led_pwm_pm_control, \
|
||||
&led_pwm_data_##id, \
|
||||
&led_pwm_config_##id, \
|
||||
POST_KERNEL, CONFIG_LED_INIT_PRIORITY, \
|
||||
&led_pwm_api);
|
||||
DEVICE_DT_INST_DEFINE(id, &led_pwm_init, led_pwm_pm_control, \
|
||||
&led_pwm_data_##id, &led_pwm_config_##id, \
|
||||
POST_KERNEL, CONFIG_LED_INIT_PRIORITY, \
|
||||
&led_pwm_api);
|
||||
|
||||
DT_INST_FOREACH_STATUS_OKAY(LED_PWM_DEVICE)
|
||||
|
|
|
@ -15,7 +15,7 @@ LOG_MODULE_REGISTER(main, CONFIG_LOG_DEFAULT_LEVEL);
|
|||
|
||||
#if DT_NODE_HAS_STATUS(DT_INST(0, pwm_leds), okay)
|
||||
#define LED_PWM_NODE_ID DT_INST(0, pwm_leds)
|
||||
#define LED_PWM_DEV_NAME DT_INST_PROP_OR(0, label, "LED_PWM_0")
|
||||
#define LED_PWM_DEV_NAME DEVICE_DT_NAME(LED_PWM_NODE_ID)
|
||||
#else
|
||||
#error "No LED PWM device found"
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue