]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/rtc/rtc-ds1374.c
Merge branch 'rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip...
[linux-2.6-omap-h63xx.git] / drivers / rtc / rtc-ds1374.c
index a5b0fc09f0c673976720b10eca2cc3ecf8ff03bb..4d32e328f6cd6b7bb2e9cf9e72748b6031f30ef6 100644 (file)
@@ -222,16 +222,16 @@ static int ds1374_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
        rtc_tm_to_time(&alarm->time, &new_alarm);
        rtc_tm_to_time(&now, &itime);
 
-       new_alarm -= itime;
-
        /* This can happen due to races, in addition to dates that are
         * truly in the past.  To avoid requiring the caller to check for
         * races, dates in the past are assumed to be in the recent past
         * (i.e. not something that we'd rather the caller know about via
         * an error), and the alarm is set to go off as soon as possible.
         */
-       if (new_alarm <= 0)
+       if (time_before_eq(new_alarm, itime))
                new_alarm = 1;
+       else
+               new_alarm -= itime;
 
        mutex_lock(&ds1374->mutex);