]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] RTC alarm and wildcards
authorRusty Russell <rusty@rustcorp.com.au>
Sun, 9 Feb 2003 10:59:32 +0000 (02:59 -0800)
committerLinus Torvalds <torvalds@home.transmeta.com>
Sun, 9 Feb 2003 10:59:32 +0000 (02:59 -0800)
(Included in 2.4)
From:  Paul Gortmaker <p_gortmaker@yahoo.com>

  Summary: Wildcards in RTC alarm settings failed to work

  Description:
   The RTC has provision for wildcards when setting the alarm; to
   use them you have to write a value higher than 0xc0 to the
   appropriate hr/min/sec entry.  The driver used 0xff, which is
   fine, but it mistakenly fed the 0xff through BIN_TO_BCD before
   writing them (which is < 0xc0) and so wildcards didn't work.
   (Thanks to Gerhard Kurz for reporting the bug.)

drivers/char/rtc.c

index cf6e7b75dbac80586d995daf96646d1590b49ac3..f531967deeaa6452a76eae461b7f18185710b719 100644 (file)
@@ -171,7 +171,7 @@ static const unsigned char days_in_mo[] =
  *     A very tiny interrupt handler. It runs with SA_INTERRUPT set,
  *     but there is possibility of conflicting with the set_rtc_mmss()
  *     call (the rtc irq and the timer irq can easily run at the same
- *     time in two different CPUs). So we need to serializes
+ *     time in two different CPUs). So we need to serialize
  *     accesses to the chip with the rtc_lock spinlock that each
  *     architecture should implement in the timer code.
  *     (See ./arch/XXXX/kernel/time.c for the set_rtc_mmss() function.)
@@ -401,22 +401,18 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel)
                min = alm_tm.tm_min;
                sec = alm_tm.tm_sec;
 
-               if (hrs >= 24)
-                       hrs = 0xff;
-
-               if (min >= 60)
-                       min = 0xff;
-
-               if (sec >= 60)
-                       sec = 0xff;
-
                spin_lock_irq(&rtc_lock);
                if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) ||
                    RTC_ALWAYS_BCD)
                {
-                       BIN_TO_BCD(sec);
-                       BIN_TO_BCD(min);
-                       BIN_TO_BCD(hrs);
+                       if (sec < 60) BIN_TO_BCD(sec);
+                       else sec = 0xff;
+
+                       if (min < 60) BIN_TO_BCD(min);
+                       else min = 0xff;
+
+                       if (hrs < 24) BIN_TO_BCD(hrs);
+                       else hrs = 0xff;
                }
                CMOS_WRITE(hrs, RTC_HOURS_ALARM);
                CMOS_WRITE(min, RTC_MINUTES_ALARM);