sleep: let's turn off the RTC alarm time ASAP
Let's be a tiny bit more careful here. Also, let's rearrange things to simplify them a bit, and to not use "r" outside of its immediate scope of validity.
This commit is contained in:
+7
-7
@@ -246,22 +246,22 @@ static int execute_s2h(usec_t hibernate_delay_sec) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = rtc_read_time(&cmp_time);
|
||||
/* Reset RTC right-away */
|
||||
r = rtc_write_wake_alarm(0);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* reset RTC */
|
||||
r = rtc_write_wake_alarm(0);
|
||||
r = rtc_read_time(&cmp_time);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
log_debug("Woke up at %"PRIu64, cmp_time);
|
||||
|
||||
/* if woken up after alarm time, hibernate */
|
||||
if (cmp_time >= wake_time)
|
||||
r = execute(hibernate_modes, hibernate_states);
|
||||
if (cmp_time < wake_time) /* We woke up before the alarm time, we are done. */
|
||||
return 0;
|
||||
|
||||
return r;
|
||||
/* If woken up after alarm time, hibernate */
|
||||
return execute(hibernate_modes, hibernate_states);
|
||||
}
|
||||
|
||||
static int help(void) {
|
||||
|
||||
Reference in New Issue
Block a user