Skip to content

Commit 21c942f

Browse files
pdgendtdanieldegrasse
authored andcommitted
drivers: regulator: shell: Fix regulator parent name completion
Shell functions targeting regulator parents used the auto-completion of regulator devices instead. Signed-off-by: Pieter De Gendt <[email protected]> (cherry picked from commit 576b3da)
1 parent f017af4 commit 21c942f

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

drivers/regulator/regulator_shell.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,12 @@ static bool device_is_regulator(const struct device *dev)
527527
return DEVICE_API_IS(regulator, dev);
528528
}
529529

530-
static void device_name_get(size_t idx, struct shell_static_entry *entry)
530+
static bool device_is_regulator_parent(const struct device *dev)
531+
{
532+
return DEVICE_API_IS(regulator_parent, dev);
533+
}
534+
535+
static void device_name_get_regulator(size_t idx, struct shell_static_entry *entry)
531536
{
532537
const struct device *dev = shell_device_filter(idx, device_is_regulator);
533538

@@ -537,7 +542,18 @@ static void device_name_get(size_t idx, struct shell_static_entry *entry)
537542
entry->subcmd = NULL;
538543
}
539544

540-
SHELL_DYNAMIC_CMD_CREATE(dsub_device_name, device_name_get);
545+
static void device_name_get_regulator_parent(size_t idx, struct shell_static_entry *entry)
546+
{
547+
const struct device *dev = shell_device_filter(idx, device_is_regulator_parent);
548+
549+
entry->syntax = (dev != NULL) ? dev->name : NULL;
550+
entry->handler = NULL;
551+
entry->help = NULL;
552+
entry->subcmd = NULL;
553+
}
554+
555+
SHELL_DYNAMIC_CMD_CREATE(dsub_device_name, device_name_get_regulator);
556+
SHELL_DYNAMIC_CMD_CREATE(dsub_device_name_parent, device_name_get_regulator_parent);
541557

542558
SHELL_STATIC_SUBCMD_SET_CREATE(
543559
sub_regulator_cmds,
@@ -579,12 +595,12 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
579595
2, 0),
580596
SHELL_CMD_ARG(errors, &dsub_device_name, SHELL_HELP("Get active errors", "<device>"),
581597
cmd_errors, 2, 0),
582-
SHELL_CMD_ARG(dvsset, &dsub_device_name,
598+
SHELL_CMD_ARG(dvsset, &dsub_device_name_parent,
583599
SHELL_HELP("Set dynamic voltage scaling state",
584600
"<device> <state identifier>"),
585601
cmd_dvsset, 3, 0),
586-
SHELL_CMD_ARG(shipmode, &dsub_device_name, SHELL_HELP("Enable ship mode", "<device>"),
587-
cmd_shipmode, 2, 0),
602+
SHELL_CMD_ARG(shipmode, &dsub_device_name_parent,
603+
SHELL_HELP("Enable ship mode", "<device>"), cmd_shipmode, 2, 0),
588604
SHELL_SUBCMD_SET_END);
589605

590606
SHELL_CMD_REGISTER(regulator, &sub_regulator_cmds, "Regulator playground",

0 commit comments

Comments
 (0)