Commit b35692eb authored by Ralf Baechle's avatar Ralf Baechle

[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: default avatarRalf Baechle <ralf@linux-mips.org>
parent 45592145
...@@ -197,6 +197,7 @@ static int ds1286_ioctl(struct inode *inode, struct file *file, ...@@ -197,6 +197,7 @@ static int ds1286_ioctl(struct inode *inode, struct file *file,
hrs = alm_tm.tm_hour; hrs = alm_tm.tm_hour;
min = alm_tm.tm_min; min = alm_tm.tm_min;
sec = alm_tm.tm_sec;
if (hrs >= 24) if (hrs >= 24)
hrs = 0xff; hrs = 0xff;
...@@ -204,9 +205,11 @@ static int ds1286_ioctl(struct inode *inode, struct file *file, ...@@ -204,9 +205,11 @@ static int ds1286_ioctl(struct inode *inode, struct file *file,
if (min >= 60) if (min >= 60)
min = 0xff; min = 0xff;
BIN_TO_BCD(sec); if (sec != 0)
BIN_TO_BCD(min); return -EINVAL;
BIN_TO_BCD(hrs);
min = BIN2BCD(min);
min = BIN2BCD(hrs);
spin_lock(&ds1286_lock); spin_lock(&ds1286_lock);
rtc_write(hrs, RTC_HOURS_ALARM); rtc_write(hrs, RTC_HOURS_ALARM);
......
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