aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
authorRabin Vincent <rabin.vincent@stericsson.com>2011-11-22 05:03:14 -0500
committerLuis Henriques <luis.henriques@canonical.com>2012-04-05 11:17:22 -0400
commit203f024ac117c4724f76fbf570c04491917b2721 (patch)
tree05a5c7018a6a99f37d9d8a74a3167eba288aaf37 /drivers/rtc
parenta7c765a58308899054f0ff52db2bf1671506c41e (diff)
rtc: Disable the alarm in the hardware (v2)
BugLink: http://bugs.launchpad.net/bugs/971808 commit 41c7f7424259ff11009449f87c95656f69f9b186 upstream. 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: 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/rtc')
-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 38d1dc74b2c..636a2ec2181 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -762,6 +762,14 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
762 return 0; 762 return 0;
763} 763}
764 764
765static void rtc_alarm_disable(struct rtc_device *rtc)
766{
767 if (!rtc->ops || !rtc->ops->alarm_irq_enable)
768 return;
769
770 rtc->ops->alarm_irq_enable(rtc->dev.parent, false);
771}
772
765/** 773/**
766 * rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue 774 * rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue
767 * @rtc rtc device 775 * @rtc rtc device
@@ -783,8 +791,10 @@ static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer)
783 struct rtc_wkalrm alarm; 791 struct rtc_wkalrm alarm;
784 int err; 792 int err;
785 next = timerqueue_getnext(&rtc->timerqueue); 793 next = timerqueue_getnext(&rtc->timerqueue);
786 if (!next) 794 if (!next) {
795 rtc_alarm_disable(rtc);
787 return; 796 return;
797 }
788 alarm.time = rtc_ktime_to_tm(next->expires); 798 alarm.time = rtc_ktime_to_tm(next->expires);
789 alarm.enabled = 1; 799 alarm.enabled = 1;
790 err = __rtc_set_alarm(rtc, &alarm); 800 err = __rtc_set_alarm(rtc, &alarm);
@@ -846,7 +856,8 @@ again:
846 err = __rtc_set_alarm(rtc, &alarm); 856 err = __rtc_set_alarm(rtc, &alarm);
847 if (err == -ETIME) 857 if (err == -ETIME)
848 goto again; 858 goto again;
849 } 859 } else
860 rtc_alarm_disable(rtc);
850 861
851 mutex_unlock(&rtc->ops_lock); 862 mutex_unlock(&rtc->ops_lock);
852} 863}