]> git.sur5r.net Git - u-boot/commitdiff
RTC: Fix month offset by one problem in M41T62 RTC driver
authorStefan Roese <sr@denx.de>
Wed, 30 Apr 2008 13:50:39 +0000 (15:50 +0200)
committerWolfgang Denk <wd@denx.de>
Sat, 3 May 2008 18:44:54 +0000 (20:44 +0200)
This patch fixes a problem with the month being read and written
incorrectly (offset by one). This only gets visible by also using
the Linux driver (rtc-m41t80).

Tested on AMCC Canyonlands.

Signed-off-by: Stefan Roese <sr@denx.de>
drivers/rtc/m41t62.c

index cf2a9574a98f146fd19a7c114fa7727e84b06a1f..89d4ccdb2c75112a6adb570e553b2971a26a0cec 100644 (file)
@@ -81,7 +81,7 @@ int rtc_get(struct rtc_time *tm)
        tm->tm_hour = BCD2BIN(buf[M41T62_REG_HOUR] & 0x3f);
        tm->tm_mday = BCD2BIN(buf[M41T62_REG_DAY] & 0x3f);
        tm->tm_wday = buf[M41T62_REG_WDAY] & 0x07;
-       tm->tm_mon = BCD2BIN(buf[M41T62_REG_MON] & 0x1f) - 1;
+       tm->tm_mon = BCD2BIN(buf[M41T62_REG_MON] & 0x1f);
 
        /* assume 20YY not 19YY, and ignore the Century Bit */
        /* U-Boot needs to add 1900 here */
@@ -119,7 +119,7 @@ void rtc_set(struct rtc_time *tm)
        buf[M41T62_REG_DAY] =
                BIN2BCD(tm->tm_mday) | (buf[M41T62_REG_DAY] & ~0x3f);
        buf[M41T62_REG_MON] =
-               BIN2BCD(tm->tm_mon + 1) | (buf[M41T62_REG_MON] & ~0x1f);
+               BIN2BCD(tm->tm_mon) | (buf[M41T62_REG_MON] & ~0x1f);
        /* assume 20YY not 19YY */
        buf[M41T62_REG_YEAR] = BIN2BCD(tm->tm_year % 100);