diff options
| author | Mao Jinlong <jinlmao@codeaurora.org> | 2017-10-12 11:27:10 +0800 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2017-10-27 00:02:38 -0700 |
| commit | ecbfe59d6558031070b59b2c580e39c15a1a3c91 (patch) | |
| tree | 3d5b04a1097130aa9694814d16af4d67310ea81d /drivers/rtc/interface.c | |
| parent | 2db878d52eef51fcc49af58f35db373ba6d09335 (diff) | |
rtc: Disable alarm irq if alarm time is in the past
If device is boot up by rtc alarm, the alarm irq will still be
enabled and the alarm time is smaller than current rtc time before
any alarm is set or canceled. If device is powered off now, it will
boot up automatically as the alarm irq is enabled.
So disable alarm irq if alarm is enabled and alarm time is in the
past.
CRs-Fixed: 2109666
Change-Id: Ie60bd1222a400cd45a6c5a385faa70190fbe7e3c
Signed-off-by: Mao Jinlong <jinlmao@codeaurora.org>
Diffstat (limited to 'drivers/rtc/interface.c')
| -rw-r--r-- | drivers/rtc/interface.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 9bb934ed2a7a..dbe70002b4fb 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -362,6 +362,14 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) } EXPORT_SYMBOL_GPL(rtc_set_alarm); +static void rtc_alarm_disable(struct rtc_device *rtc) +{ + if (!rtc->ops || !rtc->ops->alarm_irq_enable) + return; + + rtc->ops->alarm_irq_enable(rtc->dev.parent, false); +} + /* Called once per device from rtc_device_register */ int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) { @@ -389,7 +397,11 @@ int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) rtc->aie_timer.enabled = 1; timerqueue_add(&rtc->timerqueue, &rtc->aie_timer.node); + } else if (alarm->enabled && (rtc_tm_to_ktime(now).tv64 >= + rtc->aie_timer.node.expires.tv64)){ + rtc_alarm_disable(rtc); } + mutex_unlock(&rtc->ops_lock); return err; } @@ -782,14 +794,6 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer) return 0; } -static void rtc_alarm_disable(struct rtc_device *rtc) -{ - if (!rtc->ops || !rtc->ops->alarm_irq_enable) - return; - - rtc->ops->alarm_irq_enable(rtc->dev.parent, false); -} - /** * rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue * @rtc rtc device |
