Skip to content

Commit

Permalink
Merge branch 'omp-jb50354' into 'master'
Browse files Browse the repository at this point in the history
[iphb] Make RTC power on reliable. Contributes to JB#50354

See merge request mer-core/dsme!39
  • Loading branch information
spiiroin committed Aug 25, 2020
2 parents 67528a0 + c953445 commit cc6ac2c
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions modules/iphb.c
Expand Up @@ -1441,9 +1441,9 @@ static bool rtc_set_alarm_after(time_t delay)
android_alarm_clear();
linux_alarm_clear();
}

if( !rtc_set_alarm_tm(&tm, enabled) )
goto cleanup;
if (linux_alarm_timerfd == -1 && android_alarm_fd == -1)
if( !rtc_set_alarm_tm(&tm, enabled) )
goto cleanup;

result = true;

Expand All @@ -1461,6 +1461,7 @@ static void rtc_set_alarm_powerup(void)
{
time_t sys = time(0);
time_t rtc = alarm_powerup;
struct tm tm;

/* how far in the future the next poweup alarm is */
if( rtc > sys )
Expand All @@ -1484,7 +1485,10 @@ static void rtc_set_alarm_powerup(void)
/* always log the state we leave rtc wakeup on dsme exit */
log_time_t(LOG_WARNING, PFIX"powerup via RTC", rtc ? sys+rtc : 0, sys);

rtc_set_alarm_after(rtc);
if( rtc_get_time_tm(&tm) != (time_t)-1 ) {
tm.tm_sec += rtc;
rtc_set_alarm_tm(&tm, (rtc == 0) ? false: true);
}
}

/** Flag for: update system time on rtc interrupt */
Expand Down Expand Up @@ -3372,13 +3376,13 @@ void module_fini(void)
/* stop timerfd alarm */
linux_alarm_quit();

/* close android alarm device */
android_alarm_quit();

/* set wakeup alarm before closing the rtc */
rtc_set_alarm_powerup();
rtc_detach();

/* close android alarm device */
android_alarm_quit();

/* cleanup rest of what is in the epoll set */
listenfd_quit();
kernelfd_close();
Expand Down

0 comments on commit cc6ac2c

Please sign in to comment.