Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes on labels for GPIO and PWM LEDs #35300

Merged
merged 3 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions drivers/led/led_pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
19 changes: 17 additions & 2 deletions dts/bindings/gpio/gpio-leds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,28 @@ description: GPIO LEDs parent node

compatible: "gpio-leds"

include:
- name: base.yaml
property-allowlist: [label]

properties:
label:
description: |
Human readable string describing the device and used to set the device
name. It can be passed as argument to device_get_binding() to retrieve
the device. If this property is omitted, then the device name is set
from the node full name.
child-binding:
description: GPIO LED child node
properties:
gpios:
type: phandle-array
required: true
label:
required: true
required: false
type: string
description: Human readable string describing the device (used as device_get_binding() argument)
description: |
Human readable string describing the LED. It can be used by an
application to identify this LED or to retrieve its number/index
(i.e. child node number) on the parent device.
19 changes: 17 additions & 2 deletions dts/bindings/led/pwm-leds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,29 @@ description: PWM LEDs parent node

compatible: "pwm-leds"

include:
- name: base.yaml
property-allowlist: [label]

properties:
label:
description: |
Human readable string describing the device and used to set the device
name. It can be passed as argument to device_get_binding() to retrieve
the device. If this property is omitted, then the device name is set
from the node full name.

child-binding:
description: PWM LED child node
properties:
pwms:
type: phandle-array
required: true
type: phandle-array

label:
required: false
type: string
description: Human readable string describing the device (used as device_get_binding() argument)
description: |
Human readable string describing the LED. It can be used by an
application to identify this LED or to retrieve its number/index
(i.e. child node number) on the parent device.
2 changes: 1 addition & 1 deletion samples/drivers/led_pwm/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down