Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: regulator: regulator_shell: create command to print regulators #83970

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions drivers/regulator/regulator_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,19 @@ static bool device_is_regulator(const struct device *dev)
return DEVICE_API_IS(regulator, dev);
}

#define PRINT_REGULATOR_NODE_NAME(node_id, sh) \
if (device_is_regulator(device_get_binding(DT_NODE_FULL_NAME(node_id)))) { \
shell_print(sh, "%s", DT_NODE_FULL_NAME(node_id)); \
}

static void cmd_print(const struct shell *sh, size_t argc, char **argv)
{
ARG_UNUSED(argc);
ARG_UNUSED(argv);

DT_FOREACH_STATUS_OKAY_NODE_VARGS(PRINT_REGULATOR_NODE_NAME, sh);
}

static void device_name_get(size_t idx, struct shell_static_entry *entry)
{
const struct device *dev = shell_device_filter(idx, device_is_regulator);
Expand Down Expand Up @@ -609,6 +622,10 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
"Enable regulator ship mode\n"
"Usage: shipmode <device>",
cmd_shipmode, 2, 0),
SHELL_CMD(print, &dsub_device_name,
"Print the node names of available regulator device API class devices.\n"
"Usage: print",
cmd_print),
SHELL_SUBCMD_SET_END);

SHELL_CMD_REGISTER(regulator, &sub_regulator_cmds, "Regulator playground",
Expand Down
Loading