@@ -19,6 +19,15 @@
static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer);
static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer);
+static struct wakeup_source *rtc_interface_wakelock;
+static int __init rtc_interface_wakelock_init(void)
+{
+ rtc_interface_wakelock = wakeup_source_register("rtc_interface");
+ return 0;
+}
+core_initcall(rtc_interface_wakelock_init);
+
+
static int __rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm)
{
int err;
@@ -563,6 +572,7 @@ enum hrtimer_restart rtc_pie_update_irq(struct hrtimer *timer)
void rtc_update_irq(struct rtc_device *rtc,
unsigned long num, unsigned long events)
{
+ __pm_stay_awake(rtc_interface_wakelock);
schedule_work(&rtc->irqwork);
}
EXPORT_SYMBOL_GPL(rtc_update_irq);
@@ -751,9 +761,10 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
alarm.time = rtc_ktime_to_tm(timer->node.expires);
alarm.enabled = 1;
err = __rtc_set_alarm(rtc, &alarm);
- if (err == -ETIME)
+ if (err == -ETIME) {
+ __pm_stay_awake(rtc_interface_wakelock);
schedule_work(&rtc->irqwork);
- else if (err) {
+ } else if (err) {
timerqueue_del(&rtc->timerqueue, &timer->node);
timer->enabled = 0;
return err;
@@ -849,6 +860,7 @@ again:
}
mutex_unlock(&rtc->ops_lock);
+ __pm_relax(rtc_interface_wakelock);
}
To ensure suspend events don't trigger between the irq and the rtc workqueue function running, use pm_stay_awake/pm_relax. Signed-off-by: John Stultz <john.stultz@linaro.org> --- drivers/rtc/interface.c | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-)