diff options
Diffstat (limited to 'drivers/rtc/interface.c')
-rw-r--r-- | drivers/rtc/interface.c | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 3bcc7cfcaba7..ed35a6b4753f 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c | |||
@@ -323,20 +323,6 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
323 | } | 323 | } |
324 | EXPORT_SYMBOL_GPL(rtc_read_alarm); | 324 | EXPORT_SYMBOL_GPL(rtc_read_alarm); |
325 | 325 | ||
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) | 326 | static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) |
341 | { | 327 | { |
342 | struct rtc_time tm; | 328 | struct rtc_time tm; |
@@ -360,7 +346,14 @@ static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
360 | * over right here, before we set the alarm. | 346 | * over right here, before we set the alarm. |
361 | */ | 347 | */ |
362 | 348 | ||
363 | return ___rtc_set_alarm(rtc, alarm); | 349 | if (!rtc->ops) |
350 | err = -ENODEV; | ||
351 | else if (!rtc->ops->set_alarm) | ||
352 | err = -EINVAL; | ||
353 | else | ||
354 | err = rtc->ops->set_alarm(rtc->dev.parent, alarm); | ||
355 | |||
356 | return err; | ||
364 | } | 357 | } |
365 | 358 | ||
366 | int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | 359 | int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) |
@@ -776,20 +769,6 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer) | |||
776 | return 0; | 769 | return 0; |
777 | } | 770 | } |
778 | 771 | ||
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 | /** | 772 | /** |
794 | * rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue | 773 | * rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue |
795 | * @rtc rtc device | 774 | * @rtc rtc device |
@@ -811,10 +790,8 @@ static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer) | |||
811 | struct rtc_wkalrm alarm; | 790 | struct rtc_wkalrm alarm; |
812 | int err; | 791 | int err; |
813 | next = timerqueue_getnext(&rtc->timerqueue); | 792 | next = timerqueue_getnext(&rtc->timerqueue); |
814 | if (!next) { | 793 | if (!next) |
815 | rtc_alarm_disable(rtc); | ||
816 | return; | 794 | return; |
817 | } | ||
818 | alarm.time = rtc_ktime_to_tm(next->expires); | 795 | alarm.time = rtc_ktime_to_tm(next->expires); |
819 | alarm.enabled = 1; | 796 | alarm.enabled = 1; |
820 | err = __rtc_set_alarm(rtc, &alarm); | 797 | err = __rtc_set_alarm(rtc, &alarm); |
@@ -876,8 +853,7 @@ again: | |||
876 | err = __rtc_set_alarm(rtc, &alarm); | 853 | err = __rtc_set_alarm(rtc, &alarm); |
877 | if (err == -ETIME) | 854 | if (err == -ETIME) |
878 | goto again; | 855 | goto again; |
879 | } else | 856 | } |
880 | rtc_alarm_disable(rtc); | ||
881 | 857 | ||
882 | mutex_unlock(&rtc->ops_lock); | 858 | mutex_unlock(&rtc->ops_lock); |
883 | } | 859 | } |