Commit 952061352acfd24034e6990b6b7d32cded020c0a
Committed by
Tom Rini
1 parent
c1d6e0bbfd
Exists in
smarc_8mq_lf_v2020.04
and in
11 other branches
drivers: rtc: correctly convert seconds to time structure
Variable 'days' must be defined as signed int. Otherwise the conversion fails for some dates, e.g. 2004-08-25. Cf function rtc_time64_to_tm() in the Linux kernel source. Fixes: 992c1db45591 "drivers: rtc: resolve year 2038 problem in rtc_to_tm" Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Showing 1 changed file with 5 additions and 1 deletions Side-by-side Diff
drivers/rtc/rtc-lib.c
... | ... | @@ -31,10 +31,14 @@ |
31 | 31 | /* |
32 | 32 | * rtc_to_tm - Converts u64 to rtc_time. |
33 | 33 | * Convert seconds since 01-01-1970 00:00:00 to Gregorian date. |
34 | + * | |
35 | + * This function is copied from rtc_time64_to_tm() in the Linux kernel. | |
36 | + * But in U-Boot January is month 1 and we do not subtract 1900 from the year. | |
34 | 37 | */ |
35 | 38 | void rtc_to_tm(u64 time, struct rtc_time *tm) |
36 | 39 | { |
37 | - unsigned int month, year, secs, days; | |
40 | + unsigned int month, year, secs; | |
41 | + int days; | |
38 | 42 | |
39 | 43 | days = div_u64_rem(time, 86400, &secs); |
40 | 44 |