]>
Commit | Line | Data |
---|---|---|
73ce6861 GKH |
1 | From ff164ae39b82ee483b24579c8e22a13a8ce5bd04 Mon Sep 17 00:00:00 2001 |
2 | From: Riwen Lu <luriwen@kylinos.cn> | |
3 | Date: Thu, 6 Jan 2022 16:46:09 +0800 | |
4 | Subject: rtc: cmos: Evaluate century appropriate | |
5 | MIME-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ||
9 | From: Riwen Lu <luriwen@kylinos.cn> | |
10 | ||
11 | commit ff164ae39b82ee483b24579c8e22a13a8ce5bd04 upstream. | |
12 | ||
13 | There's limiting the year to 2069. When setting the rtc year to 2070, | |
14 | reading it returns 1970. Evaluate century starting from 19 to count the | |
15 | correct year. | |
16 | ||
17 | $ sudo date -s 20700106 | |
18 | Mon 06 Jan 2070 12:00:00 AM CST | |
19 | $ sudo hwclock -w | |
20 | $ sudo hwclock -r | |
21 | 1970-01-06 12:00:49.604968+08:00 | |
22 | ||
23 | Fixes: 2a4daadd4d3e5071 ("rtc: cmos: ignore bogus century byte") | |
24 | ||
25 | Signed-off-by: Riwen Lu <luriwen@kylinos.cn> | |
26 | Acked-by: Eric Wong <e@80x24.org> | |
27 | Reviewed-by: Mateusz Jończyk <mat.jonczyk@o2.pl> | |
28 | Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> | |
29 | Link: https://lore.kernel.org/r/20220106084609.1223688-1-luriwen@kylinos.cn | |
30 | Signed-off-by: Mateusz Jończyk <mat.jonczyk@o2.pl> # preparation for stable | |
31 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
32 | --- | |
33 | drivers/rtc/rtc-mc146818-lib.c | 2 +- | |
34 | 1 file changed, 1 insertion(+), 1 deletion(-) | |
35 | ||
36 | --- a/drivers/rtc/rtc-mc146818-lib.c | |
37 | +++ b/drivers/rtc/rtc-mc146818-lib.c | |
38 | @@ -83,7 +83,7 @@ unsigned int mc146818_get_time(struct rt | |
39 | time->tm_year += real_year - 72; | |
40 | #endif | |
41 | ||
42 | - if (century > 20) | |
43 | + if (century > 19) | |
44 | time->tm_year += (century - 19) * 100; | |
45 | ||
46 | /* |