Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rtc: rzn1: fix BCD to rtc_time conversion errors

tm_mon describes months from 0 to 11, but the register contains BCD from
1 to 12. tm_year contains years since 1900, but the BCD contains 20XX.
Apply the offsets when converting these numbers.

Fixes: deeb4b5393e1 ("rtc: rzn1: Add new RTC driver")
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20241113113032.27409-1-wsa+renesas@sang-engineering.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

authored by

Wolfram Sang and committed by
Alexandre Belloni
55727188 6cc79a62

+4 -4
+4 -4
drivers/rtc/rtc-rzn1.c
··· 111 111 tm->tm_hour = bcd2bin(tm->tm_hour); 112 112 tm->tm_wday = bcd2bin(tm->tm_wday); 113 113 tm->tm_mday = bcd2bin(tm->tm_mday); 114 - tm->tm_mon = bcd2bin(tm->tm_mon); 115 - tm->tm_year = bcd2bin(tm->tm_year); 114 + tm->tm_mon = bcd2bin(tm->tm_mon) - 1; 115 + tm->tm_year = bcd2bin(tm->tm_year) + 100; 116 116 117 117 return 0; 118 118 } ··· 128 128 tm->tm_hour = bin2bcd(tm->tm_hour); 129 129 tm->tm_wday = bin2bcd(rzn1_rtc_tm_to_wday(tm)); 130 130 tm->tm_mday = bin2bcd(tm->tm_mday); 131 - tm->tm_mon = bin2bcd(tm->tm_mon); 132 - tm->tm_year = bin2bcd(tm->tm_year); 131 + tm->tm_mon = bin2bcd(tm->tm_mon + 1); 132 + tm->tm_year = bin2bcd(tm->tm_year - 100); 133 133 134 134 val = readl(rtc->base + RZN1_RTC_CTL2); 135 135 if (!(val & RZN1_RTC_CTL2_STOPPED)) {