aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRabin Vincent <rabin.vincent@stericsson.com>2011-11-22 05:03:14 -0500
committerJohn Stultz <john.stultz@linaro.org>2012-01-26 22:41:42 -0500
commit41c7f7424259ff11009449f87c95656f69f9b186 (patch)
treed0923396755a299e0c21066575ace82b93697429
parent5f9679d29c7959445d4af1eb85ee55e4ebad4a93 (diff)
rtc: Disable the alarm in the hardware (v2)
Currently, the RTC code does not disable the alarm in the hardware. This means that after a sequence such as the one below (the files are in the RTC sysfs), the box will boot up after 2 minutes even though we've asked for the alarm to be turned off. # echo $((`cat since_epoch`)+120) > wakealarm # echo 0 > wakealarm # poweroff Fix this by disabling the alarm when there are no timers to run. The original version of this patch was reverted. This version disables the irq directly instead of setting a disabled timer in the future. Cc: stable@kernel.org Cc: John Stultz <john.stultz@linaro.org> Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com> [Merged in the second revision from Rabin] Signed-off-by: John Stultz <john.stultz@linaro.org>
-rw-r--r--drivers/rtc/interface.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 167e68a9ffda..dc87eda65814 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -776,6 +776,14 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
776 return 0; 776 return 0;
777} 777}
778 778
779static void rtc_alarm_disable(struct rtc_device *rtc)
780{
781 if (!rtc->ops || !rtc->ops->alarm_irq_enable)
782 return;
783
784 rtc->ops->alarm_irq_enable(rtc->dev.parent, false);
785}
786
779/** 787/**
780 * rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue 788 * rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue
781 * @rtc rtc device 789 * @rtc rtc device
@@ -797,8 +805,10 @@ static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer)
797 struct rtc_wkalrm alarm; 805 struct rtc_wkalrm alarm;
798 int err; 806 int err;
799 next = timerqueue_getnext(&rtc->timerqueue); 807 next = timerqueue_getnext(&rtc->timerqueue);
800 if (!next) 808 if (!next) {
809 rtc_alarm_disable(rtc);
801 return; 810 return;
811 }
802 alarm.time = rtc_ktime_to_tm(next->expires); 812 alarm.time = rtc_ktime_to_tm(next->expires);
803 alarm.enabled = 1; 813 alarm.enabled = 1;
804 err = __rtc_set_alarm(rtc, &alarm); 814 err = __rtc_set_alarm(rtc, &alarm);
@@ -860,7 +870,8 @@ again:
860 err = __rtc_set_alarm(rtc, &alarm); 870 err = __rtc_set_alarm(rtc, &alarm);
861 if (err == -ETIME) 871 if (err == -ETIME)
862 goto again; 872 goto again;
863 } 873 } else
874 rtc_alarm_disable(rtc);
864 875
865 mutex_unlock(&rtc->ops_lock); 876 mutex_unlock(&rtc->ops_lock);
866} 877}