pm: shorten the pm procfs domain lock time.

snprintf and procfs_memcpy don't have to do inside lock.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
This commit is contained in:
buxiasen 2024-05-24 22:05:38 +08:00 committed by Xiang Xiao
parent 112e67f863
commit 3d1b3ba1f5

View File

@ -330,6 +330,8 @@ static ssize_t pm_read_state(FAR struct file *filep, FAR char *buffer,
sum += wake[state] + sleep[state];
}
pm_domain_unlock(pmfile->domain, flags);
sum = sum ? sum : 1;
for (state = 0; state < PM_COUNT && totalsize < buflen; state++)
@ -355,8 +357,6 @@ static ssize_t pm_read_state(FAR struct file *filep, FAR char *buffer,
totalsize += copysize;
}
pm_domain_unlock(pmfile->domain, flags);
filep->f_pos += totalsize;
return totalsize;
}