From 4197b5aec87705844c7e4c17128338c215c40b54 Mon Sep 17 00:00:00 2001 From: buxiasen Date: Fri, 24 May 2024 14:47:38 +0800 Subject: [PATCH] pm: do struct timespec copy to decrease api call times. Signed-off-by: buxiasen --- drivers/power/pm/pm_changestate.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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); } /****************************************************************************