From: Youngjae Cho Date: Wed, 8 Feb 2023 03:40:14 +0000 (+0900) Subject: power: update wakeup reason immediately after wakeup X-Git-Tag: accepted/tizen/unified/20230215.100730~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=101a2f359b7cd92802dabaf8c958aa99295336ac;p=platform%2Fcore%2Fsystem%2Fdeviced.git 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 --- 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)