Skip to content

Commit 589be4e

Browse files
yishai1999fabiobaltieri
authored andcommitted
led: shell: filter device lookup using DEVICE_API macros
Filter for led devices when looking them up in dynamic shell commands. Signed-off-by: Yishai Jaffe <[email protected]>
1 parent c09930e commit 589be4e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/led/led_shell.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,14 @@ cmd_write_channels(const struct shell *sh, size_t argc, char **argv)
330330
return err;
331331
}
332332

333+
static bool device_is_led_and_ready(const struct device *dev)
334+
{
335+
return device_is_ready(dev) && DEVICE_API_IS(led, dev);
336+
}
337+
333338
static void device_name_get(size_t idx, struct shell_static_entry *entry)
334339
{
335-
const struct device *dev = shell_device_lookup(idx, NULL);
340+
const struct device *dev = shell_device_filter(idx, device_is_led_and_ready);
336341

337342
entry->syntax = (dev != NULL) ? dev->name : NULL;
338343
entry->handler = NULL;

0 commit comments

Comments
 (0)