Skip to content

Commit 93b2ec0

Browse files
neilbrownjohnstultz-work
authored andcommitted
rtc: Expire alarms after the time is set.
If the alarm time programming in the rtc is ever in the past, it won't fire, and any other alarm will be queued after it so they won't fire either. So any time that the alarm might be in the past, we need to trigger the irq handler to ensure the old alarm is cleared and the timer queue is fully in the future. This can happen: - when we first initialise the alarm - when we set the time in the rtc. so follow both of these by scheduling the timer work function. CC: stable@kernel.org Signed-off-by: NeilBrown <neilb@suse.de> [Also catch set_mmss case -jstultz] Signed-off-by: John Stultz <john.stultz@linaro.org>
1 parent c9c024b commit 93b2ec0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/rtc/interface.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
7373
err = -EINVAL;
7474

7575
mutex_unlock(&rtc->ops_lock);
76+
/* A timer might have just expired */
77+
schedule_work(&rtc->irqwork);
7678
return err;
7779
}
7880
EXPORT_SYMBOL_GPL(rtc_set_time);
@@ -112,6 +114,8 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs)
112114
err = -EINVAL;
113115

114116
mutex_unlock(&rtc->ops_lock);
117+
/* A timer might have just expired */
118+
schedule_work(&rtc->irqwork);
115119

116120
return err;
117121
}
@@ -403,6 +407,8 @@ int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
403407
timerqueue_add(&rtc->timerqueue, &rtc->aie_timer.node);
404408
}
405409
mutex_unlock(&rtc->ops_lock);
410+
/* maybe that was in the past.*/
411+
schedule_work(&rtc->irqwork);
406412
return err;
407413
}
408414
EXPORT_SYMBOL_GPL(rtc_initialize_alarm);

0 commit comments

Comments
 (0)