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:
parent
14fa2873b5
commit
0b2648ff40
1 changed files with 6 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue