diff options
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/interface.c | 50 |
1 files changed, 10 insertions, 40 deletions
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 3bcc7cfcaba7..8e286259a007 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c | |||
@@ -73,8 +73,6 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm) | |||
73 | err = -EINVAL; | 73 | err = -EINVAL; |
74 | 74 | ||
75 | mutex_unlock(&rtc->ops_lock); | 75 | mutex_unlock(&rtc->ops_lock); |
76 | /* A timer might have just expired */ | ||
77 | schedule_work(&rtc->irqwork); | ||
78 | return err; | 76 | return err; |
79 | } | 77 | } |
80 | EXPORT_SYMBOL_GPL(rtc_set_time); | 78 | EXPORT_SYMBOL_GPL(rtc_set_time); |
@@ -114,8 +112,6 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs) | |||
114 | err = -EINVAL; | 112 | err = -EINVAL; |
115 | 113 | ||
116 | mutex_unlock(&rtc->ops_lock); | 114 | mutex_unlock(&rtc->ops_lock); |
117 | /* A timer might have just expired */ | ||
118 | schedule_work(&rtc->irqwork); | ||
119 | 115 | ||
120 | return err; | 116 | return err; |
121 | } | 117 | } |
@@ -323,20 +319,6 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
323 | } | 319 | } |
324 | EXPORT_SYMBOL_GPL(rtc_read_alarm); | 320 | EXPORT_SYMBOL_GPL(rtc_read_alarm); |
325 | 321 | ||
326 | static int ___rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | ||
327 | { | ||
328 | int err; | ||
329 | |||
330 | if (!rtc->ops) | ||
331 | err = -ENODEV; | ||
332 | else if (!rtc->ops->set_alarm) | ||
333 | err = -EINVAL; | ||
334 | else | ||
335 | err = rtc->ops->set_alarm(rtc->dev.parent, alarm); | ||
336 | |||
337 | return err; | ||
338 | } | ||
339 | |||
340 | static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | 322 | static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) |
341 | { | 323 | { |
342 | struct rtc_time tm; | 324 | struct rtc_time tm; |
@@ -360,7 +342,14 @@ static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
360 | * over right here, before we set the alarm. | 342 | * over right here, before we set the alarm. |
361 | */ | 343 | */ |
362 | 344 | ||
363 | return ___rtc_set_alarm(rtc, alarm); | 345 | if (!rtc->ops) |
346 | err = -ENODEV; | ||
347 | else if (!rtc->ops->set_alarm) | ||
348 | err = -EINVAL; | ||
349 | else | ||
350 | err = rtc->ops->set_alarm(rtc->dev.parent, alarm); | ||
351 | |||
352 | return err; | ||
364 | } | 353 | } |
365 | 354 | ||
366 | int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | 355 | int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) |
@@ -407,8 +396,6 @@ int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
407 | timerqueue_add(&rtc->timerqueue, &rtc->aie_timer.node); | 396 | timerqueue_add(&rtc->timerqueue, &rtc->aie_timer.node); |
408 | } | 397 | } |
409 | mutex_unlock(&rtc->ops_lock); | 398 | mutex_unlock(&rtc->ops_lock); |
410 | /* maybe that was in the past.*/ | ||
411 | schedule_work(&rtc->irqwork); | ||
412 | return err; | 399 | return err; |
413 | } | 400 | } |
414 | EXPORT_SYMBOL_GPL(rtc_initialize_alarm); | 401 | EXPORT_SYMBOL_GPL(rtc_initialize_alarm); |
@@ -776,20 +763,6 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer) | |||
776 | return 0; | 763 | return 0; |
777 | } | 764 | } |
778 | 765 | ||
779 | static void rtc_alarm_disable(struct rtc_device *rtc) | ||
780 | { | ||
781 | struct rtc_wkalrm alarm; | ||
782 | struct rtc_time tm; | ||
783 | |||
784 | __rtc_read_time(rtc, &tm); | ||
785 | |||
786 | alarm.time = rtc_ktime_to_tm(ktime_add(rtc_tm_to_ktime(tm), | ||
787 | ktime_set(300, 0))); | ||
788 | alarm.enabled = 0; | ||
789 | |||
790 | ___rtc_set_alarm(rtc, &alarm); | ||
791 | } | ||
792 | |||
793 | /** | 766 | /** |
794 | * rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue | 767 | * rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue |
795 | * @rtc rtc device | 768 | * @rtc rtc device |
@@ -811,10 +784,8 @@ static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer) | |||
811 | struct rtc_wkalrm alarm; | 784 | struct rtc_wkalrm alarm; |
812 | int err; | 785 | int err; |
813 | next = timerqueue_getnext(&rtc->timerqueue); | 786 | next = timerqueue_getnext(&rtc->timerqueue); |
814 | if (!next) { | 787 | if (!next) |
815 | rtc_alarm_disable(rtc); | ||
816 | return; | 788 | return; |
817 | } | ||
818 | alarm.time = rtc_ktime_to_tm(next->expires); | 789 | alarm.time = rtc_ktime_to_tm(next->expires); |
819 | alarm.enabled = 1; | 790 | alarm.enabled = 1; |
820 | err = __rtc_set_alarm(rtc, &alarm); | 791 | err = __rtc_set_alarm(rtc, &alarm); |
@@ -876,8 +847,7 @@ again: | |||
876 | err = __rtc_set_alarm(rtc, &alarm); | 847 | err = __rtc_set_alarm(rtc, &alarm); |
877 | if (err == -ETIME) | 848 | if (err == -ETIME) |
878 | goto again; | 849 | goto again; |
879 | } else | 850 | } |
880 | rtc_alarm_disable(rtc); | ||
881 | 851 | ||
882 | mutex_unlock(&rtc->ops_lock); | 852 | mutex_unlock(&rtc->ops_lock); |
883 | } | 853 | } |