aboutsummaryrefslogtreecommitdiff
path: root/drivers/rtc/rtc-ds1374.c
diff options
context:
space:
mode:
authorRoel Kluin <roel.kluin@gmail.com>2009-03-31 15:25:00 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-01 08:59:26 -0700
commitfa7af8b1bb6dfca7a0c8541683a9bfffbc8dd345 (patch)
treee13f984d52f16ab82f5842d1f2267e13b8c06e36 /drivers/rtc/rtc-ds1374.c
parentc08cf9daf66844c60ebe9f89885d3a3e1893e61f (diff)
rtc: test before subtraction on unsigned
new_alarm is unsigned so test before the subtraction. [akpm@linux-foundation.org: time-wrapping fix] Signed-off-by: Roel Kluin <roel.kluin@gmail.com> Cc: David Brownell <david-b@pacbell.net> Cc: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-ds1374.c')
-rw-r--r--drivers/rtc/rtc-ds1374.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index a5b0fc09f0c..4d32e328f6c 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -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);