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/7.0/unified/20230220.064529~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F24%2F288224%2F1;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)