Commit 0072b78be2b41e5a0ca3ddc39335574dc2e855bd

Authored by Stefan Roese
Committed by Wolfgang Denk
1 parent 50f93d30da

RTC: Fix month offset by one problem in M41T62 RTC driver

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>

Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff

drivers/rtc/m41t62.c
... ... @@ -81,7 +81,7 @@
81 81 tm->tm_hour = BCD2BIN(buf[M41T62_REG_HOUR] & 0x3f);
82 82 tm->tm_mday = BCD2BIN(buf[M41T62_REG_DAY] & 0x3f);
83 83 tm->tm_wday = buf[M41T62_REG_WDAY] & 0x07;
84   - tm->tm_mon = BCD2BIN(buf[M41T62_REG_MON] & 0x1f) - 1;
  84 + tm->tm_mon = BCD2BIN(buf[M41T62_REG_MON] & 0x1f);
85 85  
86 86 /* assume 20YY not 19YY, and ignore the Century Bit */
87 87 /* U-Boot needs to add 1900 here */
... ... @@ -119,7 +119,7 @@
119 119 buf[M41T62_REG_DAY] =
120 120 BIN2BCD(tm->tm_mday) | (buf[M41T62_REG_DAY] & ~0x3f);
121 121 buf[M41T62_REG_MON] =
122   - BIN2BCD(tm->tm_mon + 1) | (buf[M41T62_REG_MON] & ~0x1f);
  122 + BIN2BCD(tm->tm_mon) | (buf[M41T62_REG_MON] & ~0x1f);
123 123 /* assume 20YY not 19YY */
124 124 buf[M41T62_REG_YEAR] = BIN2BCD(tm->tm_year % 100);
125 125