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 <yishai1999@gmail.com>
This commit is contained in:
parent
c09930ed30
commit
589be4e49c
1 changed files with 6 additions and 1 deletions
|
@ -330,9 +330,14 @@ cmd_write_channels(const struct shell *sh, size_t argc, char **argv)
|
|||
return err;
|
||||
}
|
||||
|
||||
static bool device_is_led_and_ready(const struct device *dev)
|
||||
{
|
||||
return device_is_ready(dev) && DEVICE_API_IS(led, dev);
|
||||
}
|
||||
|
||||
static void device_name_get(size_t idx, struct shell_static_entry *entry)
|
||||
{
|
||||
const struct device *dev = shell_device_lookup(idx, NULL);
|
||||
const struct device *dev = shell_device_filter(idx, device_is_led_and_ready);
|
||||
|
||||
entry->syntax = (dev != NULL) ? dev->name : NULL;
|
||||
entry->handler = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue