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 <fabiobaltieri@google.com>
This commit is contained in:
Fabio Baltieri 2024-04-23 17:48:14 +01:00 committed by Alberto Escolar
parent df819a8609
commit 4257fb6a3d

View file

@ -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 = {