Skip to content

Commit

Permalink
rtc: sc27xx: Always read normal alarm when registering RTC device
Browse files Browse the repository at this point in the history
When registering one RTC device, it will check to see if there is an
alarm already set in RTC hardware by reading RTC alarm, at this time
we should always read the normal alarm put in always-on region by
checking the rtc->registered flag.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
  • Loading branch information
Baolin Wang authored and Alexandre Belloni committed Oct 25, 2018
1 parent bf2c532 commit 3822d1b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/rtc/rtc-sc27xx.c
Original file line number Diff line number Diff line change
@@ -415,10 +415,14 @@ static int sprd_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
u32 val;

/*
* If aie_timer is enabled, we should get the normal alarm time.
* Before RTC device is registered, it will check to see if there is an
* alarm already set in RTC hardware, and we always read the normal
* alarm at this time.
*
* Or if aie_timer is enabled, we should get the normal alarm time.
* Otherwise we should get auxiliary alarm time.
*/
if (rtc->rtc && rtc->rtc->aie_timer.enabled == 0)
if (rtc->rtc && rtc->rtc->registered && rtc->rtc->aie_timer.enabled == 0)
return sprd_rtc_read_aux_alarm(dev, alrm);

ret = sprd_rtc_get_secs(rtc, SPRD_RTC_ALARM, &secs);

0 comments on commit 3822d1b

Please sign in to comment.