From 6ba32743731fdb09af922bec37a9b9b7e3c6595e Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Sun, 26 Jan 2025 02:41:55 +0000 Subject: [PATCH] rtc_shell: add shell device filtering Add shell device filtering using DEVICE_API_IS. Signed-off-by: Fabio Baltieri --- drivers/rtc/rtc_shell.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/rtc/rtc_shell.c b/drivers/rtc/rtc_shell.c index 93e530998903..2ea8ba3047d2 100644 --- a/drivers/rtc/rtc_shell.c +++ b/drivers/rtc/rtc_shell.c @@ -217,9 +217,14 @@ static int cmd_get(const struct shell *sh, size_t argc, char **argv) return 0; } +static bool device_is_rtc(const struct device *dev) +{ + return DEVICE_API_IS(rtc, 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_rtc); entry->syntax = (dev != NULL) ? dev->name : NULL; entry->handler = NULL;