diff options
author | Troy Kisky <troy.kisky@boundarydevices.com> | 2013-04-22 14:41:52 -0700 |
---|---|---|
committer | Eric Nelson <eric.nelson@boundarydevices.com> | 2013-09-03 14:06:21 -0700 |
commit | f77b900212e1e98015b30854dec4b5e75492bc85 (patch) | |
tree | 7cdcf3ea5f41890c6b998d3fc15d057c5555a345 /drivers | |
parent | 2494d6ef19523065817754c8dabdb9834760f378 (diff) |
rtc: interface: add check_alarm_past
add call to check_alarm_past to rtc_initialize_alarm.
That way the queue won't be stopped waiting for a time
that will never happen.
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/rtc/interface.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 636a2ec21810..45e4b7f5fcd5 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -318,7 +318,7 @@ 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) +static int check_alarm_past(struct rtc_device *rtc, struct rtc_wkalrm *alarm) { struct rtc_time tm; long now, scheduled; @@ -332,8 +332,16 @@ static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) /* Make sure we're not setting alarms in the past */ err = __rtc_read_time(rtc, &tm); rtc_tm_to_time(&tm, &now); - if (scheduled <= now) + if (scheduled <= now) { + pr_info("%s: alarm in the past\n", __func__); return -ETIME; + } + return 0; +} + +static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) +{ + int err = check_alarm_past(rtc, alarm); /* * XXX - We just checked to make sure the alarm time is not * in the past, but there is still a race window where if @@ -341,12 +349,15 @@ static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) * over right here, before we set the alarm. */ + if (err) + return err; if (!rtc->ops) err = -ENODEV; else if (!rtc->ops->set_alarm) err = -EINVAL; - else + else { err = rtc->ops->set_alarm(rtc->dev.parent, alarm); + } return err; } @@ -378,10 +389,9 @@ EXPORT_SYMBOL_GPL(rtc_set_alarm); /* Called once per device from rtc_device_register */ int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) { - int err; + int err = check_alarm_past(rtc, alarm); - err = rtc_valid_tm(&alarm->time); - if (err != 0) + if (err) return err; err = mutex_lock_interruptible(&rtc->ops_lock); |