Skip to content

Commit

Permalink
Revert "rtc: Disable the alarm in the hardware"
Browse files Browse the repository at this point in the history
commit 157e8bf upstream.

This reverts commit c0afabd.

It causes failures on Toshiba laptops - instead of disabling the alarm,
it actually seems to enable it on the affected laptops, resulting in
(for example) the laptop powering on automatically five minutes after
shutdown.

There's a patch for it that appears to work for at least some people,
but it's too late to play around with this, so revert for now and try
again in the next merge window.

See for example

	http://bugs.debian.org/652869

Reported-and-bisected-by: Andreas Friedrich <[email protected]> (Toshiba Tecra)
Reported-by: Antonio-M. Corbi Bellot <[email protected]> (Toshiba Portege R500)
Reported-by: Marco Santos <[email protected]> (Toshiba Portege Z830)
Reported-by: Christophe Vu-Brugier <[email protected]>  (Toshiba Portege R830)
Cc: Jonathan Nieder <[email protected]>
Requested-by: John Stultz <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
torvalds authored and gregkh committed Jan 6, 2012
1 parent c61e023 commit b47f3ad
Showing 1 changed file with 10 additions and 34 deletions.
44 changes: 10 additions & 34 deletions drivers/rtc/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,20 +318,6 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
}
EXPORT_SYMBOL_GPL(rtc_read_alarm);

static int ___rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
{
int err;

if (!rtc->ops)
err = -ENODEV;
else if (!rtc->ops->set_alarm)
err = -EINVAL;
else
err = rtc->ops->set_alarm(rtc->dev.parent, alarm);

return err;
}

static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
{
struct rtc_time tm;
Expand All @@ -355,7 +341,14 @@ static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
* over right here, before we set the alarm.
*/

return ___rtc_set_alarm(rtc, alarm);
if (!rtc->ops)
err = -ENODEV;
else if (!rtc->ops->set_alarm)
err = -EINVAL;
else
err = rtc->ops->set_alarm(rtc->dev.parent, alarm);

return err;
}

int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
Expand Down Expand Up @@ -769,20 +762,6 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
return 0;
}

static void rtc_alarm_disable(struct rtc_device *rtc)
{
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.enabled = 0;

___rtc_set_alarm(rtc, &alarm);
}

/**
* rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue
* @rtc rtc device
Expand All @@ -804,10 +783,8 @@ static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer)
struct rtc_wkalrm alarm;
int err;
next = timerqueue_getnext(&rtc->timerqueue);
if (!next) {
rtc_alarm_disable(rtc);
if (!next)
return;
}
alarm.time = rtc_ktime_to_tm(next->expires);
alarm.enabled = 1;
err = __rtc_set_alarm(rtc, &alarm);
Expand Down Expand Up @@ -869,8 +846,7 @@ void rtc_timer_do_work(struct work_struct *work)
err = __rtc_set_alarm(rtc, &alarm);
if (err == -ETIME)
goto again;
} else
rtc_alarm_disable(rtc);
}

mutex_unlock(&rtc->ops_lock);
}
Expand Down

0 comments on commit b47f3ad

Please sign in to comment.