power: update wakeup reason immediately after wakeup 24/288224/1
authorYoungjae Cho <y0.cho@samsung.com>
Wed, 8 Feb 2023 03:40:14 +0000 (12:40 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Tue, 14 Feb 2023 03:15:03 +0000 (12:15 +0900)
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 <y0.cho@samsung.com>
src/power/power-suspend.c

index 39866a6..04728bb 100644 (file)
@@ -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)