From a9bd208b5bd14e9c7229a00652708ee3a7765044 Mon Sep 17 00:00:00 2001 From: Wentong Wu Date: Wed, 22 Jan 2020 03:29:50 -0500 Subject: [PATCH] Power: change sys_pm_force_power_state only works for one shot Change sys_pm_force_power_state only works for the current ongoing suspend operation, before the end of syspend state forced_pm_state will be cleared. Signed-off-by: Wentong Wu --- include/power/power.h | 13 ++++++------- subsys/power/power.c | 2 ++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/power/power.h b/include/power/power.h index e392b914c1f..fb73ca2fd59 100644 --- a/include/power/power.h +++ b/include/power/power.h @@ -146,14 +146,13 @@ static inline void _sys_pm_idle_exit_notification_disable(void) /** * @brief Force usage of given power state. * - * This function overrides decision made by PM policy - * forcing usage of given power state in all subsequent - * suspend operations. Forcing the SYS_POWER_STATE_AUTO - * state restores normal operation. + * This function overrides decision made by PM policy forcing + * usage of given power state in the ongoing suspend operation. + * And before the end of suspend, the state of forced_pm_state + * is cleared with interrupt disabled. * - * @param state Power state which should be used in all - * subsequent suspend operations or - * SYS_POWER_STATE_AUTO. + * @param state Power state which should be used in the ongoing + * suspend operation or SYS_POWER_STATE_AUTO. */ void sys_pm_force_power_state(enum power_states state); diff --git a/subsys/power/power.c b/subsys/power/power.c index cbf1b5fa439..9a10e9ea9f7 100644 --- a/subsys/power/power.c +++ b/subsys/power/power.c @@ -152,6 +152,8 @@ enum power_states _sys_suspend(s32_t ticks) if (!post_ops_done) { post_ops_done = 1; + /* clear forced_pm_state */ + forced_pm_state = SYS_POWER_STATE_AUTO; sys_pm_notify_power_state_exit(pm_state); _sys_pm_power_state_exit_post_ops(pm_state); }