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:
Yishai Jaffe 2024-12-01 18:02:13 +02:00 committed by Fabio Baltieri
commit 589be4e49c

View file

@ -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;