regulator_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
0b2648ff40
commit
f3dac37f8a
1 changed files with 6 additions and 1 deletions
|
|
@ -522,9 +522,14 @@ static int cmd_shipmode(const struct shell *sh, size_t argc, char **argv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool device_is_regulator(const struct device *dev)
|
||||||
|
{
|
||||||
|
return DEVICE_API_IS(regulator, dev);
|
||||||
|
}
|
||||||
|
|
||||||
static void device_name_get(size_t idx, struct shell_static_entry *entry)
|
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_regulator);
|
||||||
|
|
||||||
entry->syntax = (dev != NULL) ? dev->name : NULL;
|
entry->syntax = (dev != NULL) ? dev->name : NULL;
|
||||||
entry->handler = NULL;
|
entry->handler = NULL;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue