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

drivers/rtc/test: Update driver to address y2038/y2106 issues

This driver has a number of y2038/y2106 issues.

This patch resolves them by:

- Replacing get_seconds() with ktime_get_real_seconds()
- Replacing rtc_time_to_tm() with rtc_time64_to_tm()

Also add test_rtc_set_mmss64() for testing rtc_class_ops's
set_mmss64(), which can be activated by "test_mmss64" module
parameter.

Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Acked-by: Alessandro Zummo <a.zummo@towertech.it>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1427945681-29972-9-git-send-email-john.stultz@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Xunlei Pang and committed by
Ingo Molnar
4d644ab8 8e4ff1a8

+17 -2
+17 -2
drivers/rtc/rtc-test.c
··· 13 13 #include <linux/rtc.h> 14 14 #include <linux/platform_device.h> 15 15 16 + static int test_mmss64; 17 + module_param(test_mmss64, int, 0644); 18 + MODULE_PARM_DESC(test_mmss64, "Test struct rtc_class_ops.set_mmss64()."); 19 + 16 20 static struct platform_device *test0 = NULL, *test1 = NULL; 17 21 18 22 static int test_rtc_read_alarm(struct device *dev, ··· 34 30 static int test_rtc_read_time(struct device *dev, 35 31 struct rtc_time *tm) 36 32 { 37 - rtc_time_to_tm(get_seconds(), tm); 33 + rtc_time64_to_tm(ktime_get_real_seconds(), tm); 34 + return 0; 35 + } 36 + 37 + static int test_rtc_set_mmss64(struct device *dev, time64_t secs) 38 + { 39 + dev_info(dev, "%s, secs = %lld\n", __func__, (long long)secs); 38 40 return 0; 39 41 } 40 42 ··· 65 55 return 0; 66 56 } 67 57 68 - static const struct rtc_class_ops test_rtc_ops = { 58 + static struct rtc_class_ops test_rtc_ops = { 69 59 .proc = test_rtc_proc, 70 60 .read_time = test_rtc_read_time, 71 61 .read_alarm = test_rtc_read_alarm, ··· 110 100 { 111 101 int err; 112 102 struct rtc_device *rtc; 103 + 104 + if (test_mmss64) { 105 + test_rtc_ops.set_mmss64 = test_rtc_set_mmss64; 106 + test_rtc_ops.set_mmss = NULL; 107 + } 113 108 114 109 rtc = devm_rtc_device_register(&plat_dev->dev, "test", 115 110 &test_rtc_ops, THIS_MODULE);