diff options
author | Joseph Yoon <tyoon@nvidia.com> | 2012-02-29 18:02:49 +0900 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2013-09-14 01:10:12 -0700 |
commit | a18afa4ecc5db68af0fef1a6456d0d239733d312 (patch) | |
tree | ed58edbbffbdbd68fa1c299d2a458cbca8b067d0 /drivers/rtc/rtc-max8907c.c | |
parent | 16f14f6fcd3edeec0ffa4988ce1fcb06e7289176 (diff) |
rtc: max8907c: correct month index calculation.
max8907c is returning Jan as 1 from rtc register.
but kernel is assuming Jan as 0.
so correct month index.
Change-Id: I9b77b89952442891f53ebd6355352f36a07521cd
Signed-off-by: Joseph Yoon <tyoon@nvidia.com>
Reviewed-on: http://git-master/r/86561
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Rebase-Id: R2a6aa05d32db42c5555d4d194c633351397ae242
Diffstat (limited to 'drivers/rtc/rtc-max8907c.c')
-rw-r--r-- | drivers/rtc/rtc-max8907c.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/rtc/rtc-max8907c.c b/drivers/rtc/rtc-max8907c.c index d4cd11ae5bc8..732976195dae 100644 --- a/drivers/rtc/rtc-max8907c.c +++ b/drivers/rtc/rtc-max8907c.c @@ -61,8 +61,10 @@ static int tm_calc(struct rtc_time *tm, u8 *buf, int len) + (buf[RTC_YEAR1] >> 4) * 10 + (buf[RTC_YEAR1] & 0xf); tm->tm_year -= 1900; + /* RTC month index issue in max8907c + : January index is 1 but kernel assumes it as 0 */ tm->tm_mon = ((buf[RTC_MONTH] >> 4) & 0x01) * 10 - + (buf[RTC_MONTH] & 0x0f); + + (buf[RTC_MONTH] & 0x0f) - 1; tm->tm_mday = ((buf[RTC_DATE] >> 4) & 0x03) * 10 + (buf[RTC_DATE] & 0x0f); tm->tm_wday = buf[RTC_WEEKDAY] & 0x07; @@ -98,10 +100,13 @@ static int data_calc(u8 *buf, struct rtc_time *tm, int len) low = low - high * 10; high = high - (high / 10) * 10; buf[RTC_YEAR1] = (high << 4) + low; - high = tm->tm_mon / 10; - low = tm->tm_mon; - low = low - high * 10; + + /* RTC month index issue in max8907c + : January index is 1 but kernel assumes it as 0 */ + high = (tm->tm_mon + 1) / 10; + low = (tm->tm_mon + 1) % 10; buf[RTC_MONTH] = (high << 4) + low; + high = tm->tm_mday / 10; low = tm->tm_mday; low = low - high * 10; |