]> err.no Git - linux-2.6/commitdiff
[PATCH] I2C: ds1337 - fix 12/24 hour mode bug
authorLadislav Michl <ladis@linux-mips.org>
Fri, 29 Jul 2005 19:15:00 +0000 (12:15 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 29 Jul 2005 20:12:50 +0000 (13:12 -0700)
DS1339 manual, page 6, chapter Date and time operation:
  The DS1339 can be run in either 12-hour or 24-hour mode. Bit 6 of the
  hours register is defined as the 12-hour or 24-hour mode-select bit.
  When high, the 12-hour mode is selected.

Patch below makes ds1337 driver work as documented in manual.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/i2c/chips/ds1337.c

index 74ece8ac1c2355b214af3e4481eddf3c747a5fd6..82cf959989fd3f3126ea83255a57e2e8c659fb1d 100644 (file)
@@ -165,7 +165,7 @@ static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt)
        buf[0] = 0;             /* reg offset */
        buf[1] = BIN2BCD(dt->tm_sec);
        buf[2] = BIN2BCD(dt->tm_min);
-       buf[3] = BIN2BCD(dt->tm_hour) | (1 << 6);
+       buf[3] = BIN2BCD(dt->tm_hour);
        buf[4] = BIN2BCD(dt->tm_wday) + 1;
        buf[5] = BIN2BCD(dt->tm_mday);
        buf[6] = BIN2BCD(dt->tm_mon) + 1;
@@ -344,9 +344,9 @@ static void ds1337_init_client(struct i2c_client *client)
 
        /* Ensure that device is set in 24-hour mode */
        val = i2c_smbus_read_byte_data(client, DS1337_REG_HOUR);
-       if ((val >= 0) && (val & (1 << 6)) == 0)
+       if ((val >= 0) && (val & (1 << 6)))
                i2c_smbus_write_byte_data(client, DS1337_REG_HOUR,
-                                         val | (1 << 6));
+                                         val & 0x3f);
 }
 
 static int ds1337_detach_client(struct i2c_client *client)