I2C: ds1337 - fix 12/24 hour mode bug
PATCH 1/1 I2C: ds1337 - fix 12/24 hour mode bug
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.
drivers/i2c/chips/ds1337.c: needs update
Index: drivers/i2c/chips/ds1337.c
===================================================================
drivers/i2c/chips/ds1337.c (mode:100644) +3 -3
@@ -165,7 +165,7 @@ 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 @@ /* 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)
[email protected]
Appliedpatch i2c-ds1337-12-24-mode-fix.patch added to gregkh-2.6 tree
This is a note to let you know that I've just added the patch titled
Subject: I2C: ds1337 - fix 12/24 hour mode bug
to my gregkh-2.6 tree. Its filename is
i2c-ds1337-12-24-mode-fix.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
Patches currently in gregkh-2.6 which might be from [email protected] are
devfs/devfs-remove-devfs-tape.patchdevfs/devfs-die-die-die.patchdevfs/devfs-remove-devfs_mk_symlink.patchdevfs/devfs-remove-devfs_mk_bdev.patchdevfs/devfs-remove-devfs_mk_dir.patchdevfs/devfs-scrub-partitions.patchdevfs/devfs-scrub-init.patchdevfs/devfs-remove-devfs_mk_cdev.patchdevfs/devfs-remove-devfs_remove.patchdevfs/devfs-remove-devfs_fs_kernel.h.patchdevfs/devfs-remove-misc-devfs_name.patchdevfs/devfs-remove-genhd-devfs_name.patchdevfs/devfs-remove-videodev-devfs_name.patchdevfs/devfs-remove-serial-devfs_name.patchdevfs/devfs-remove-ide-devfs_name.patchdevfs/devfs-remove-line-devfs_name.patchdevfs/devfs-remove-scsi-devfs_name.patchdevfs/devfs-remove-tty-devfs_name.patchdevfs/devfs-remove-usb-mode.patchdevfs/devfs-tty_driver_no_devfs.patchdevfs/devfs-minor-cleanups.patchdevfs/devfs-remove-documentation.patchdevfs/ndevfs.patchdriver/securityfs.patchdriver/driver-sample.sh.patchgregkh/gregkh-debugfs_example.patchgregkh/gregkh-kobject-warn.patchgregkh/gregkh-laptop-sysrq.patchgregkh/gregkh-usb-hacking.patchgregkh/gregkh-usb-minors.patchi2c/i2c-max6875-documentation-update.patchi2c/i2c-max6875-simplify.patchi2c/i2c-mpc-restore-code-removed.patchi2c/i2c-hwmon-class-01.patchi2c/i2c-hwmon-class-02.patchi2c/i2c-hwmon-class-03.patchi2c/i2c-missing-space.patchi2c/i2c-ds1337-12-24-mode-fix.patchi2c/i2c-nforce2-cleanup.patchpci/pci-acpi-mcfg-04.patch
Quoted 1 line
From [email protected] Mon Jul 25 10:41:08 2005
Date: Mon, 25 Jul 2005 10:24:36 +0200
To: Greg KH <[email protected]>
Cc: James Chapman <[email protected]>,
LKML <[email protected]>
Subject: I2C: ds1337 - fix 12/24 hour mode bug
Message-ID: <20050725082436.GA10186@orphique>
From: Ladislav Michl <[email protected]>
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.
--- drivers/i2c/chips/ds1337.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/chips/ds1337.c +3 -3
@@ -165,7 +165,7 @@ 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 @@/* 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)