kernel: alarm: :fix the BUG that device automatically powers on
The value of alarm.time is invalid if we get it by:
memset(&alarm, 0, sizeof(alarm)).
So function of rtc_set_alarm aborts before it really calls into:
rtc->ops->set_alarm.
Then we can`t disable the RTC alarm by that. The result is some
alarms enabled by alarm_suspend are not disabled correctly during
alarm_resume. And device will automatically power on.
CRs-fixed: 524051
Change-Id: Ibc99e62878d17ad4f50325630bf0862207e2cf3f
Signed-off-by: Figo Wang <figow@codeaurora.org>
diff --git a/drivers/rtc/alarm.c b/drivers/rtc/alarm.c
index cc2049d..1648cba 100644
--- a/drivers/rtc/alarm.c
+++ b/drivers/rtc/alarm.c
@@ -455,7 +455,7 @@
rtc_delta.tv_sec, rtc_delta.tv_nsec);
if (rtc_current_time + 1 >= rtc_alarm_time) {
pr_alarm(SUSPEND, "alarm about to go off\n");
- memset(&rtc_alarm, 0, sizeof(rtc_alarm));
+ rtc_time_to_tm(0, &rtc_alarm.time);
rtc_alarm.enabled = 0;
rtc_set_alarm(alarm_rtc_dev, &rtc_alarm);
@@ -480,7 +480,7 @@
pr_alarm(SUSPEND, "alarm_resume(%p)\n", pdev);
- memset(&alarm, 0, sizeof(alarm));
+ rtc_time_to_tm(0, &alarm.time);
alarm.enabled = 0;
rtc_set_alarm(alarm_rtc_dev, &alarm);