i2c_shell: add device filtering

Add shell device name filtering using DEVICE_API_IS.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
Fabio Baltieri 2025-01-17 21:06:09 +00:00 committed by Benjamin Cabé
parent 14fa2873b5
commit 0b2648ff40

View file

@ -336,9 +336,14 @@ static int cmd_i2c_speed(const struct shell *shell_ctx, size_t argc, char **argv
return 0;
}
static bool device_is_i2c(const struct device *dev)
{
return DEVICE_API_IS(i2c, dev) || DEVICE_API_IS(i3c, 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_i2c);
entry->syntax = (dev != NULL) ? dev->name : NULL;
entry->handler = NULL;