pm: do struct timespec copy to decrease api call times.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
This commit is contained in:
buxiasen 2024-05-24 14:47:38 +08:00 committed by Xiang Xiao
parent e0396327a2
commit 4197b5aec8
1 changed files with 7 additions and 5 deletions

View File

@ -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);
}
/****************************************************************************