Comments
Patch
From fa83fa95ffb2279f2af80316583b18b784537245 Mon Sep 17 00:00:00 2001
From: Jeremy Compostella <jeremy.compostella@gmail.com>
Date: Wed, 4 Jan 2012 21:03:38 +0100
Subject: [PATCH] rtc: Fix unexpected poweron and unnecessary alarm disabling
On my laptop 3.2.0-rc6 I have unexpected poweron after shutdown
300 seconds later. I found out that the "hwclock --systohw" plays with
UIE which lead to the rtc_disable_rtc() function call. This function
disables the alarm by setting the alarm 300 seconds later with the
disable flag which does not seems to be the best way since we could
disable the appropriate alarm instead.
Moreover, the rtc_timer_do_work calls the rtc_alarm_disable event if
there is no alarm to disable. Therefore, during the boot time, a
disabled alarm is set 300 seconds in the future which does not make
sense.
Signed-off-by: Jeremy Compostella <jeremy.compostella@gmail.com>
---
drivers/rtc/interface.c | 16 ++++++----------
1 files changed, 6 insertions(+), 10 deletions(-)
@@ -776,15 +776,11 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
return 0;
}
-static void rtc_alarm_disable(struct rtc_device *rtc)
+static void rtc_alarm_disable(struct rtc_device *rtc, ktime_t time)
{
struct rtc_wkalrm alarm;
- struct rtc_time tm;
-
- __rtc_read_time(rtc, &tm);
- alarm.time = rtc_ktime_to_tm(ktime_add(rtc_tm_to_ktime(tm),
- ktime_set(300, 0)));
+ alarm.time = rtc_ktime_to_tm(time);
alarm.enabled = 0;
___rtc_set_alarm(rtc, &alarm);
@@ -812,7 +808,7 @@ static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer)
int err;
next = timerqueue_getnext(&rtc->timerqueue);
if (!next) {
- rtc_alarm_disable(rtc);
+ rtc_alarm_disable(rtc, timer->node.expires);
return;
}
alarm.time = rtc_ktime_to_tm(next->expires);
@@ -835,7 +831,7 @@ static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer)
*/
void rtc_timer_do_work(struct work_struct *work)
{
- struct rtc_timer *timer;
+ struct rtc_timer *timer = NULL;
struct timerqueue_node *next;
ktime_t now;
struct rtc_time tm;
@@ -876,8 +872,8 @@ again:
err = __rtc_set_alarm(rtc, &alarm);
if (err == -ETIME)
goto again;
- } else
- rtc_alarm_disable(rtc);
+ } else if (timer && timer->enabled == 0)
+ rtc_alarm_disable(rtc, timer->node.expires);
mutex_unlock(&rtc->ops_lock);
}
--
1.7.2.5