From 4257fb6a3d118d5d69709e9d627675973071411b Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Tue, 23 Apr 2024 17:48:14 +0100 Subject: [PATCH] shell: device_service: show the usage conter when pm runtime is enabled Add an extra "usage=%d" to the device status to show the current usage counter when PM runtime is enabled. Signed-off-by: Fabio Baltieri --- subsys/shell/modules/device_service.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/subsys/shell/modules/device_service.c b/subsys/shell/modules/device_service.c index fec4b25f6b..f702651cfd 100644 --- a/subsys/shell/modules/device_service.c +++ b/subsys/shell/modules/device_service.c @@ -64,6 +64,7 @@ static int cmd_device_list(const struct shell *sh, char buf[20]; const char *name = get_device_name(dev, buf, sizeof(buf)); const char *state = "READY"; + int usage; shell_fprintf(sh, SHELL_NORMAL, "- %s", name); if (!device_is_ready(dev)) { @@ -79,7 +80,13 @@ static int cmd_device_list(const struct shell *sh, #endif /* CONFIG_PM_DEVICE */ } - shell_fprintf(sh, SHELL_NORMAL, " (%s)\n", state); + usage = pm_device_runtime_usage(dev); + if (usage >= 0) { + shell_fprintf(sh, SHELL_NORMAL, " (%s, usage=%d)\n", state, usage); + } else { + shell_fprintf(sh, SHELL_NORMAL, " (%s)\n", state); + } + #ifdef CONFIG_DEVICE_DEPS if (!k_is_user_context()) { struct cmd_device_list_visitor_context ctx = {