pmconfig: update pmconfig dump
UNAME_MACHINE | UNAME_PLATFORM)
#endif
+#ifndef CONFIG_NSH_PROC_MOUNTPOINT
+# define CONFIG_NSH_PROC_MOUNTPOINT "/proc"
+#endif
+
/****************************************************************************
* Private Data
****************************************************************************/
@@ -172,6 +176,30 @@ int cmd_shutdown(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
****************************************************************************/
#if defined(CONFIG_PM) && !defined(CONFIG_NSH_DISABLE_PMCONFIG)
+static int cmd_pmconfig_recursive(FAR struct nsh_vtbl_s *vtbl,
+ FAR const char *dirpath,
+ FAR struct dirent *entryp,
+ FAR void *pvarg)
+{
+ char *path;
+ int ret = ERROR;
+
+ if (DIRENT_ISDIRECTORY(entryp->d_type))
+ {
+ return 0;
+ }
+
+ path = nsh_getdirpath(vtbl, dirpath, entryp->d_name);
+ if (path)
+ {
+ nsh_output(vtbl, "\n%s:\n", path);
+ ret = nsh_catfile(vtbl, pvarg, path);
+ free(path);
+ }
+
+ return ret;
+}
+
int cmd_pmconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
struct boardioc_pm_ctrl_s ctrl =
@@ -182,10 +210,6 @@ int cmd_pmconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
int next_state;
int last_state;
- int normal_count;
- int idle_count;
- int standby_count;
- int sleep_count;
if (argc == 2)
{
@@ -200,27 +224,12 @@ int cmd_pmconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
boardctl(BOARDIOC_PM_CONTROL, (uintptr_t)&ctrl);
next_state = ctrl.state;
- ctrl.action = BOARDIOC_PM_STAYCOUNT;
- ctrl.state = PM_NORMAL;
- boardctl(BOARDIOC_PM_CONTROL, (uintptr_t)&ctrl);
- normal_count = ctrl.count;
-
- ctrl.state = PM_IDLE;
- boardctl(BOARDIOC_PM_CONTROL, (uintptr_t)&ctrl);
- idle_count = ctrl.count;
-
- ctrl.state = PM_STANDBY;
- boardctl(BOARDIOC_PM_CONTROL, (uintptr_t)&ctrl);
- standby_count = ctrl.count;
-
- ctrl.state = PM_SLEEP;
- boardctl(BOARDIOC_PM_CONTROL, (uintptr_t)&ctrl);
- sleep_count = ctrl.count;
+ nsh_output(vtbl, "Last state %d, Next state %d\n",
+ last_state, next_state);
- nsh_output(vtbl, "Last state %d, Next state %d"
- "PM stay [%d, %d, %d, %d]\n",
- last_state, next_state, normal_count, idle_count,
- standby_count, sleep_count);
+ return nsh_foreach_direntry(vtbl, argv[0],
+ CONFIG_NSH_PROC_MOUNTPOINT "/pm",
+ cmd_pmconfig_recursive, argv[0]);
}
else if (argc <= 4)
{
