Skip to content

Commit e8224c3

Browse files
committed
samples: servo_motor: Convert to use DEVICE_DT_GET
Replace device_get_binding with DEVICE_DT_GET for getting access to the pwm controller device. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
1 parent a6ffcdb commit e8224c3

File tree

1 file changed

+3
-6
lines changed
  • samples/basic/servo_motor/src

1 file changed

+3
-6
lines changed

samples/basic/servo_motor/src/main.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717

1818
#if !DT_NODE_HAS_STATUS(PWM_NODE, okay)
1919
#error "Unsupported board: pwm-servo devicetree alias is not defined or enabled"
20-
#define PWM_LABEL ""
21-
#else
22-
#define PWM_LABEL DT_LABEL(PWM_NODE)
2320
#endif
2421

2522
/*
@@ -45,9 +42,9 @@ void main(void)
4542

4643
printk("Servomotor control\n");
4744

48-
pwm = device_get_binding(PWM_LABEL);
49-
if (!pwm) {
50-
printk("Error: didn't find %s device\n", PWM_LABEL);
45+
pwm = DEVICE_DT_GET(PWM_NODE);
46+
if (!device_is_ready(pwm)) {
47+
printk("Error: PWM device %s is not ready\n", pwm->name);
5148
return;
5249
}
5350

0 commit comments

Comments
 (0)