aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/interface.c')
-rw-r--r--drivers/rtc/interface.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 7cbdc9228dd5..bac1eeb3d312 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -265,8 +265,10 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
265 return err; 265 return err;
266 266
267 /* full-function RTCs won't have such missing fields */ 267 /* full-function RTCs won't have such missing fields */
268 if (rtc_valid_tm(&alarm->time) == 0) 268 if (rtc_valid_tm(&alarm->time) == 0) {
269 rtc_add_offset(rtc, &alarm->time);
269 return 0; 270 return 0;
271 }
270 272
271 /* get the "after" timestamp, to detect wrapped fields */ 273 /* get the "after" timestamp, to detect wrapped fields */
272 err = rtc_read_time(rtc, &now); 274 err = rtc_read_time(rtc, &now);
@@ -409,7 +411,6 @@ static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
409 if (err) 411 if (err)
410 return err; 412 return err;
411 413
412 rtc_subtract_offset(rtc, &alarm->time);
413 scheduled = rtc_tm_to_time64(&alarm->time); 414 scheduled = rtc_tm_to_time64(&alarm->time);
414 415
415 /* Make sure we're not setting alarms in the past */ 416 /* Make sure we're not setting alarms in the past */
@@ -426,6 +427,8 @@ static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
426 * over right here, before we set the alarm. 427 * over right here, before we set the alarm.
427 */ 428 */
428 429
430 rtc_subtract_offset(rtc, &alarm->time);
431
429 if (!rtc->ops) 432 if (!rtc->ops)
430 err = -ENODEV; 433 err = -ENODEV;
431 else if (!rtc->ops->set_alarm) 434 else if (!rtc->ops->set_alarm)
@@ -441,6 +444,11 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
441{ 444{
442 int err; 445 int err;
443 446
447 if (!rtc->ops)
448 return -ENODEV;
449 else if (!rtc->ops->set_alarm)
450 return -EINVAL;
451
444 err = rtc_valid_tm(&alarm->time); 452 err = rtc_valid_tm(&alarm->time);
445 if (err != 0) 453 if (err != 0)
446 return err; 454 return err;
@@ -462,7 +470,6 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
462 470
463 mutex_unlock(&rtc->ops_lock); 471 mutex_unlock(&rtc->ops_lock);
464 472
465 rtc_add_offset(rtc, &alarm->time);
466 return err; 473 return err;
467} 474}
468EXPORT_SYMBOL_GPL(rtc_set_alarm); 475EXPORT_SYMBOL_GPL(rtc_set_alarm);