drivers: rtc: mc146818: changes for y2k test
The year needs to be corrected to an offset from 1900. Signed-off-by: Christopher Friedt <cfriedt@meta.com>
This commit is contained in:
parent
84d8841497
commit
bf4977e41b
1 changed files with 3 additions and 3 deletions
|
@ -191,8 +191,8 @@ static int rtc_mc146818_set_time(const struct device *dev, const struct rtc_time
|
||||||
value = rtc_read(RTC_DATA);
|
value = rtc_read(RTC_DATA);
|
||||||
rtc_write(RTC_DATA, value | RTC_UCI_BIT);
|
rtc_write(RTC_DATA, value | RTC_UCI_BIT);
|
||||||
|
|
||||||
year = (1970 + timeptr->tm_year) % 100;
|
year = (1900 + timeptr->tm_year) % 100;
|
||||||
cent = (1970 + timeptr->tm_year) / 100;
|
cent = (1900 + timeptr->tm_year) / 100;
|
||||||
|
|
||||||
if (!(rtc_read(RTC_DATA) & RTC_DMODE_BIT)) {
|
if (!(rtc_read(RTC_DATA) & RTC_DMODE_BIT)) {
|
||||||
rtc_write(RTC_SEC, (uint8_t)bin2bcd(timeptr->tm_sec));
|
rtc_write(RTC_SEC, (uint8_t)bin2bcd(timeptr->tm_sec));
|
||||||
|
@ -271,7 +271,7 @@ static int rtc_mc146818_get_time(const struct device *dev, struct rtc_time *tim
|
||||||
timeptr->tm_sec = bcd2bin(timeptr->tm_sec);
|
timeptr->tm_sec = bcd2bin(timeptr->tm_sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
timeptr->tm_year = 100 * (int)cent + year - 1970;
|
timeptr->tm_year = 100 * (int)cent + year - 1900;
|
||||||
|
|
||||||
timeptr->tm_nsec = 0;
|
timeptr->tm_nsec = 0;
|
||||||
timeptr->tm_yday = 0;
|
timeptr->tm_yday = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue