Skip to content

Commit

Permalink
rtc: fix ds1388 time corruption
Browse files Browse the repository at this point in the history
The ds1307 driver misreads the ds1388 registers when checking for 12 or 24
hour mode.  Instead of checking the hour register it reads the minute
register.  Therefore the driver thinks minutes >= 40 has the 12HR bit set
and resets the minute register by zeroing the high bits.  This results in
minutes are reset to 0-9, jumping back in time 40 or 50 minutes.  The time
jump is also written back to the RTC.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Cc: Wan ZongShun <mcuos.com@gmail.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Paul Gortmaker <p_gortmaker@yahoo.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Joakim Tjernlund authored and Linus Torvalds committed Jun 29, 2010
1 parent a02875a commit 96fc3a4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/rtc/rtc-ds1307.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ static int __devinit ds1307_probe(struct i2c_client *client,

read_rtc:
/* read RTC registers */
tmp = ds1307->read_block_data(ds1307->client, 0, 8, buf);
tmp = ds1307->read_block_data(ds1307->client, ds1307->offset, 8, buf);
if (tmp != 8) {
pr_debug("read error %d\n", tmp);
err = -EIO;
Expand Down Expand Up @@ -862,7 +862,7 @@ static int __devinit ds1307_probe(struct i2c_client *client,
if (ds1307->regs[DS1307_REG_HOUR] & DS1307_BIT_PM)
tmp += 12;
i2c_smbus_write_byte_data(client,
DS1307_REG_HOUR,
ds1307->offset + DS1307_REG_HOUR,
bin2bcd(tmp));
}

Expand Down

0 comments on commit 96fc3a4

Please sign in to comment.