diff options
author | Oliver Graute | 2022-04-26 09:26:12 +0200 |
---|---|---|
committer | Tom Rini | 2022-05-05 15:06:02 -0400 |
commit | 8b42439ad19f1b3920541c357d5d7e9593adc420 (patch) | |
tree | 755b37ec6c449c1c032080e62c77bff024bdfe04 /drivers/rtc | |
parent | 274347030631141f3e6259b2ec4fcd11365dd9a3 (diff) |
rtc: rv8803: fix off-by-one in month counting
tm_mon has a range from 0..11, but the RTC expects 1..12. So we adapt
the month accordingly. This was determined when comparing the driver
with the corresponding linux kernel driver.
Signed-off-by: Oliver Graute <oliver.graute@kococonnector.com>
Reviewed-by: Michael Walle <michael@walle.cc>
Reviewed-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/rv8803.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/rtc/rv8803.c b/drivers/rtc/rv8803.c index 5bae39d6e09..06a4ae89fa9 100644 --- a/drivers/rtc/rv8803.c +++ b/drivers/rtc/rv8803.c @@ -49,7 +49,7 @@ static int rv8803_rtc_set(struct udevice *dev, const struct rtc_time *tm) printf("WARNING: year should be between 2000 and 2099!\n"); buf[RTC_YR_REG_ADDR] = bin2bcd(tm->tm_year % 100); - buf[RTC_MON_REG_ADDR] = bin2bcd(tm->tm_mon); + buf[RTC_MON_REG_ADDR] = bin2bcd(tm->tm_mon + 1); buf[RTC_DAY_REG_ADDR] = 1 << (tm->tm_wday & 0x7); buf[RTC_DATE_REG_ADDR] = bin2bcd(tm->tm_mday); buf[RTC_HR_REG_ADDR] = bin2bcd(tm->tm_hour); @@ -90,7 +90,7 @@ static int rv8803_rtc_get(struct udevice *dev, struct rtc_time *tm) tm->tm_min = bcd2bin(buf[RTC_MIN_REG_ADDR] & 0x7F); tm->tm_hour = bcd2bin(buf[RTC_HR_REG_ADDR] & 0x3F); tm->tm_mday = bcd2bin(buf[RTC_DATE_REG_ADDR] & 0x3F); - tm->tm_mon = bcd2bin(buf[RTC_MON_REG_ADDR] & 0x1F); + tm->tm_mon = bcd2bin(buf[RTC_MON_REG_ADDR] & 0x1F) - 1; tm->tm_year = bcd2bin(buf[RTC_YR_REG_ADDR]) + 2000; tm->tm_wday = fls(buf[RTC_DAY_REG_ADDR] & 0x7F) - 1; tm->tm_yday = 0; |