Commit 93b2ec01 authored by NeilBrown's avatar NeilBrown Committed by John Stultz

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: default avatarNeilBrown <neilb@suse.de>
[Also catch set_mmss case -jstultz]
Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
parent c9c024b3
...@@ -73,6 +73,8 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm) ...@@ -73,6 +73,8 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
err = -EINVAL; err = -EINVAL;
mutex_unlock(&rtc->ops_lock); mutex_unlock(&rtc->ops_lock);
/* A timer might have just expired */
schedule_work(&rtc->irqwork);
return err; return err;
} }
EXPORT_SYMBOL_GPL(rtc_set_time); EXPORT_SYMBOL_GPL(rtc_set_time);
...@@ -112,6 +114,8 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs) ...@@ -112,6 +114,8 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs)
err = -EINVAL; err = -EINVAL;
mutex_unlock(&rtc->ops_lock); mutex_unlock(&rtc->ops_lock);
/* A timer might have just expired */
schedule_work(&rtc->irqwork);
return err; return err;
} }
...@@ -403,6 +407,8 @@ int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) ...@@ -403,6 +407,8 @@ int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
timerqueue_add(&rtc->timerqueue, &rtc->aie_timer.node); timerqueue_add(&rtc->timerqueue, &rtc->aie_timer.node);
} }
mutex_unlock(&rtc->ops_lock); mutex_unlock(&rtc->ops_lock);
/* maybe that was in the past.*/
schedule_work(&rtc->irqwork);
return err; return err;
} }
EXPORT_SYMBOL_GPL(rtc_initialize_alarm); EXPORT_SYMBOL_GPL(rtc_initialize_alarm);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment