diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2007-03-07 19:14:25 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2007-03-07 20:10:30 -0500 |
commit | b35692ebdef0c1cd4a05a58559a94ced54ff9c82 (patch) | |
tree | 3161106dfae3b4a83c6ca65bbf8a99eb62402915 /drivers/char/ds1286.c | |
parent | 455921451a176d90c5cfef898f061bb6fc83faaf (diff) |
[CHAR] ds1286: Fix handling of seconds in RTC_ALM_SET ioctl.
o Fix use of uninitialized variable sec.
o Make the RTC_ALM_SET ioctl return -EINVAL for non-zero seconds - the
DS1286 has no second field for the alarm time.
o Replace the obscure BIN_TO_BCD macro with BIN2BCD.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'drivers/char/ds1286.c')
-rw-r--r-- | drivers/char/ds1286.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/char/ds1286.c b/drivers/char/ds1286.c index 6d58b0370802..59146e3365ba 100644 --- a/drivers/char/ds1286.c +++ b/drivers/char/ds1286.c | |||
@@ -197,6 +197,7 @@ static int ds1286_ioctl(struct inode *inode, struct file *file, | |||
197 | 197 | ||
198 | hrs = alm_tm.tm_hour; | 198 | hrs = alm_tm.tm_hour; |
199 | min = alm_tm.tm_min; | 199 | min = alm_tm.tm_min; |
200 | sec = alm_tm.tm_sec; | ||
200 | 201 | ||
201 | if (hrs >= 24) | 202 | if (hrs >= 24) |
202 | hrs = 0xff; | 203 | hrs = 0xff; |
@@ -204,9 +205,11 @@ static int ds1286_ioctl(struct inode *inode, struct file *file, | |||
204 | if (min >= 60) | 205 | if (min >= 60) |
205 | min = 0xff; | 206 | min = 0xff; |
206 | 207 | ||
207 | BIN_TO_BCD(sec); | 208 | if (sec != 0) |
208 | BIN_TO_BCD(min); | 209 | return -EINVAL; |
209 | BIN_TO_BCD(hrs); | 210 | |
211 | min = BIN2BCD(min); | ||
212 | min = BIN2BCD(hrs); | ||
210 | 213 | ||
211 | spin_lock(&ds1286_lock); | 214 | spin_lock(&ds1286_lock); |
212 | rtc_write(hrs, RTC_HOURS_ALARM); | 215 | rtc_write(hrs, RTC_HOURS_ALARM); |