Commit 34529e84 authored by Ben Dooks's avatar Ben Dooks Committed by Russell King

[ARM PATCH] 2272/1: S3C2410 - rtc should check for <0 on alarm set

Patch from Ben Dooks

Since alarm fields can be ints, there is the posibility
that the alarm set code needs to check for <0 as a
valid posibility for `any`

Signed-off-by: Ben Dooks
Signed-off-by: Russell King
parent f71ea0fb
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
* Changelog: * Changelog:
* 08-Nov-2004 BJD Initial creation * 08-Nov-2004 BJD Initial creation
* 12-Nov-2004 BJD Added periodic IRQ and PM code * 12-Nov-2004 BJD Added periodic IRQ and PM code
* 22-Nov-2004 BJD Sign-test on alarm code to check for <0
*/ */
#include <linux/module.h> #include <linux/module.h>
...@@ -236,26 +237,26 @@ static int s3c2410_rtc_setalarm(struct rtc_wkalrm *alrm) ...@@ -236,26 +237,26 @@ static int s3c2410_rtc_setalarm(struct rtc_wkalrm *alrm)
struct rtc_time *tm = &alrm->time; struct rtc_time *tm = &alrm->time;
unsigned int alrm_en; unsigned int alrm_en;
pr_debug("s3c2410_rtc_setalarm: %d, %02x.%02x.%02x %02x/%02x/%02x\n", pr_debug("s3c2410_rtc_setalarm: %d, %02x/%02x/%02x %02x.%02x.%02x\n",
alrm->enabled, alrm->enabled,
tm->tm_year & 0xff, tm->tm_mon & 0xff, tm->tm_mday & 0xff, tm->tm_mday & 0xff, tm->tm_mon & 0xff, tm->tm_year & 0xff,
tm->tm_hour, tm->tm_min, tm->tm_sec); tm->tm_hour & 0xff, tm->tm_min & 0xff, tm->tm_sec);
if (alrm->enabled || 1) { if (alrm->enabled || 1) {
alrm_en = readb(S3C2410_RTCALM) & S3C2410_RTCALM_ALMEN; alrm_en = readb(S3C2410_RTCALM) & S3C2410_RTCALM_ALMEN;
writeb(0x00, S3C2410_RTCALM); writeb(0x00, S3C2410_RTCALM);
if (tm->tm_sec < 60) { if (tm->tm_sec < 60 && tm->tm_sec >= 0) {
alrm_en |= S3C2410_RTCALM_SECEN; alrm_en |= S3C2410_RTCALM_SECEN;
writeb(BIN2BCD(tm->tm_sec), S3C2410_ALMSEC); writeb(BIN2BCD(tm->tm_sec), S3C2410_ALMSEC);
} }
if (tm->tm_min < 60) { if (tm->tm_min < 60 && tm->tm_min >= 0) {
alrm_en |= S3C2410_RTCALM_MINEN; alrm_en |= S3C2410_RTCALM_MINEN;
writeb(BIN2BCD(tm->tm_min), S3C2410_ALMMIN); writeb(BIN2BCD(tm->tm_min), S3C2410_ALMMIN);
} }
if (tm->tm_hour < 24) { if (tm->tm_hour < 24 && tm->tm_hour >= 0) {
alrm_en |= S3C2410_RTCALM_HOUREN; alrm_en |= S3C2410_RTCALM_HOUREN;
writeb(BIN2BCD(tm->tm_hour), S3C2410_ALMHOUR); writeb(BIN2BCD(tm->tm_hour), S3C2410_ALMHOUR);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment