shell: device: show PM state in device list

Show current power management state in the list of devices, which is
helpful during PM debugging.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
This commit is contained in:
Marcin Niestroj 2020-01-21 23:21:00 +01:00 committed by Anas Nashif
commit 4f1626851b

View file

@ -86,8 +86,19 @@ static int cmd_device_list(const struct shell *shell,
shell_fprintf(shell, SHELL_NORMAL, "devices:\n");
for (info = __device_init_start; info != __device_init_end; info++) {
if (info->driver_api != NULL) {
shell_fprintf(shell, SHELL_NORMAL, "- %s\n",
shell_fprintf(shell, SHELL_NORMAL, "- %s",
info->config->name);
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT
u32_t state = DEVICE_PM_ACTIVE_STATE;
int err;
err = device_get_power_state(info, &state);
if (!err) {
shell_fprintf(shell, SHELL_NORMAL, " (%s)",
device_pm_state_str(state));
}
#endif /* CONFIG_DEVICE_POWER_MANAGEMENT */
shell_fprintf(shell, SHELL_NORMAL, "\n");
}
}