From 5a4031664c7c8d4bc6f60777e629ee98a6fdd8d7 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Wed, 8 Feb 2023 12:40:14 +0900 Subject: [PATCH] power: update wakeup reason immediately after wakeup The wakeup reason would be utilized by callback of device_notify(). Therefore update it on resuming. To prevent the wakeup reason from lingering, reset it by 0 before returning the function. Change-Id: I149b2999f14a1c2461098506bd64a242d66937fd Signed-off-by: Youngjae Cho --- src/power/power-suspend.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/power/power-suspend.c b/src/power/power-suspend.c index 39866a6..04728bb 100644 --- a/src/power/power-suspend.c +++ b/src/power/power-suspend.c @@ -397,11 +397,21 @@ static void suspend_echo_mem(void) { sys_set_str("/sys/power/state", "mem"); - device_notify(DEVICE_NOTIFIER_POWER_RESUME_FROM_ECHO_MEM, NULL); - // resume update_wakeup_reason(); + + device_notify(DEVICE_NOTIFIER_POWER_RESUME_FROM_ECHO_MEM, NULL); power_request_change_state(DEVICED_POWER_STATE_NORMAL, (int) wakeup_reason); + /* + * FIXME: If the wakeup reason lingers after wakeup, a transition triggered from other + * than the above line would take the lingering wakeup reason as a transition reason, + * which might not be correct for that transition. Therefore reset the wakeup reason by UNKNOWN. + * + * To address this problem, it is necessary to decide transition reason at the time when + * the transition is requested, not the time when it is executed. If then, the below resetting + * line can be removed. + */ + wakeup_reason = HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN; } static void resume_echo_mem(void) -- 2.7.4