diff options
author | Joseph Yoon <tyoon@nvidia.com> | 2012-02-29 18:02:49 +0900 |
---|---|---|
committer | Simone Willett <swillett@nvidia.com> | 2012-02-29 17:06:16 -0800 |
commit | 7401ece5369ddf4b780b207171e89902348e66ae (patch) | |
tree | e7b0676d92a2f564885e70ae4fa2eaad7dd6cdff /drivers/rtc | |
parent | 6ab11b6ed9c0c1e7174ebb572842d47826431d67 (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>
Diffstat (limited to 'drivers/rtc')
-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 668bc43461ba..f7287021da3c 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; |