diff --git a/drivers/power/pm/pm_changestate.c b/drivers/power/pm/pm_changestate.c index 0fadd2ee2e..6773508073 100644 --- a/drivers/power/pm/pm_changestate.c +++ b/drivers/power/pm/pm_changestate.c @@ -57,11 +57,17 @@ #ifdef CONFIG_PM_PROCFS static void pm_stats(FAR struct pm_domain_s *dom, int curstate, int newstate) { + struct timespec now; struct timespec ts; - clock_systime_timespec(&ts); + clock_systime_timespec(&now); + ts = now; clock_timespec_subtract(&ts, &dom->start, &ts); + /* Update start */ + + dom->start = now; + if (newstate == PM_RESTORE) { /* Wakeup from WFI */ @@ -76,10 +82,6 @@ static void pm_stats(FAR struct pm_domain_s *dom, int curstate, int newstate) clock_timespec_add(&ts, &dom->wake[curstate], &dom->wake[curstate]); dom->in_sleep = true; } - - /* Update start */ - - clock_systime_timespec(&dom->start); } /****************************************************************************