Skip to content

Commit

Permalink
rtc_shell: add shell device filtering
Browse files Browse the repository at this point in the history
Add shell device filtering using DEVICE_API_IS.

Signed-off-by: Fabio Baltieri <[email protected]>
  • Loading branch information
fabiobaltieri authored and kartben committed Jan 29, 2025
1 parent 2575bfc commit 6ba3274
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/rtc/rtc_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6ba3274

Please sign in to comment.