diff options
| author | Olof Johansson <olof@lixom.net> | 2011-12-13 19:35:03 -0800 | 
|---|---|---|
| committer | Olof Johansson <olof@lixom.net> | 2011-12-13 19:35:03 -0800 | 
| commit | 2da994e687f7991cc76e3270c423bf6500b9424a (patch) | |
| tree | 437d685035c2a39395f14c233831422ed636c016 /drivers/rtc/interface.c | |
| parent | 00e929808a1cb410f45a620c0fc79d8d0a2506b1 (diff) | |
| parent | db33f4de9952af112b0d4f2436ce931ae632aba0 (diff) | |
Merge branch 'orion/devel' into next/devel
Diffstat (limited to 'drivers/rtc/interface.c')
| -rw-r--r-- | drivers/rtc/interface.c | 44 | 
1 files changed, 34 insertions, 10 deletions
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 8e286259a007..fa4d9f324189 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -319,6 +319,20 @@ 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; @@ -342,14 +356,7 @@ static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)  	 * over right here, before we set the 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; +	return ___rtc_set_alarm(rtc, alarm);  }  int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) @@ -763,6 +770,20 @@ 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 @@ -784,8 +805,10 @@ 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) +		if (!next) { +			rtc_alarm_disable(rtc);  			return; +		}  		alarm.time = rtc_ktime_to_tm(next->expires);  		alarm.enabled = 1;  		err = __rtc_set_alarm(rtc, &alarm); @@ -847,7 +870,8 @@ again:  		err = __rtc_set_alarm(rtc, &alarm);  		if (err == -ETIME)  			goto again; -	} +	} else +		rtc_alarm_disable(rtc);  	mutex_unlock(&rtc->ops_lock);  }  | 
