Skip to content

Commit 41c7f74

Browse files
vitkyrkajohnstultz-work
authored andcommitted
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>
1 parent 5f9679d commit 41c7f74

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

drivers/rtc/interface.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,14 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
776776
return 0;
777777
}
778778

779+
static 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+
779787
/**
780788
* rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue
781789
* @rtc rtc device
@@ -797,8 +805,10 @@ static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer)
797805
struct rtc_wkalrm alarm;
798806
int err;
799807
next = timerqueue_getnext(&rtc->timerqueue);
800-
if (!next)
808+
if (!next) {
809+
rtc_alarm_disable(rtc);
801810
return;
811+
}
802812
alarm.time = rtc_ktime_to_tm(next->expires);
803813
alarm.enabled = 1;
804814
err = __rtc_set_alarm(rtc, &alarm);
@@ -860,7 +870,8 @@ void rtc_timer_do_work(struct work_struct *work)
860870
err = __rtc_set_alarm(rtc, &alarm);
861871
if (err == -ETIME)
862872
goto again;
863-
}
873+
} else
874+
rtc_alarm_disable(rtc);
864875

865876
mutex_unlock(&rtc->ops_lock);
866877
}

0 commit comments

Comments
 (0)