diff options
| author | Xunlei Pang <pang.xunlei@linaro.org> | 2015-04-01 23:34:27 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2015-04-03 02:18:24 -0400 |
| commit | 8e4ff1a81aa91d12856287c7103d0301ac91351a (patch) | |
| tree | cf42bb0295c0e6accd4453645573fa625c3e64ce /drivers/rtc | |
| parent | cb850717b076d979058d52529e15f1736359d811 (diff) | |
drivers/rtc: Provide y2038 safe rtc_class_ops.set_mmss() replacement
Currently the rtc_class_op's set_mmss() function takes a 32-bit
second value (on 32-bit systems), which is problematic for dates
past y2038.
This patch provides a safe version named set_mmss64() using
y2038 safe time64_t.
After this patch, set_mmss() is deprecated and all its users
will be fixed to use set_mmss64(), it can be removed when having
no users.
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
[jstultz: Add whitespace fix for checkpatch]
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-8-git-send-email-john.stultz@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'drivers/rtc')
| -rw-r--r-- | drivers/rtc/interface.c | 8 | ||||
| -rw-r--r-- | drivers/rtc/systohc.c | 5 |
2 files changed, 11 insertions, 2 deletions
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 37215cf983e9..d43ee409a5f2 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c | |||
| @@ -72,7 +72,11 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm) | |||
| 72 | err = -ENODEV; | 72 | err = -ENODEV; |
| 73 | else if (rtc->ops->set_time) | 73 | else if (rtc->ops->set_time) |
| 74 | err = rtc->ops->set_time(rtc->dev.parent, tm); | 74 | err = rtc->ops->set_time(rtc->dev.parent, tm); |
| 75 | else if (rtc->ops->set_mmss) { | 75 | else if (rtc->ops->set_mmss64) { |
| 76 | time64_t secs64 = rtc_tm_to_time64(tm); | ||
| 77 | |||
| 78 | err = rtc->ops->set_mmss64(rtc->dev.parent, secs64); | ||
| 79 | } else if (rtc->ops->set_mmss) { | ||
| 76 | time64_t secs64 = rtc_tm_to_time64(tm); | 80 | time64_t secs64 = rtc_tm_to_time64(tm); |
| 77 | err = rtc->ops->set_mmss(rtc->dev.parent, secs64); | 81 | err = rtc->ops->set_mmss(rtc->dev.parent, secs64); |
| 78 | } else | 82 | } else |
| @@ -96,6 +100,8 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs) | |||
| 96 | 100 | ||
| 97 | if (!rtc->ops) | 101 | if (!rtc->ops) |
| 98 | err = -ENODEV; | 102 | err = -ENODEV; |
| 103 | else if (rtc->ops->set_mmss64) | ||
| 104 | err = rtc->ops->set_mmss64(rtc->dev.parent, secs); | ||
| 99 | else if (rtc->ops->set_mmss) | 105 | else if (rtc->ops->set_mmss) |
| 100 | err = rtc->ops->set_mmss(rtc->dev.parent, secs); | 106 | err = rtc->ops->set_mmss(rtc->dev.parent, secs); |
| 101 | else if (rtc->ops->read_time && rtc->ops->set_time) { | 107 | else if (rtc->ops->read_time && rtc->ops->set_time) { |
diff --git a/drivers/rtc/systohc.c b/drivers/rtc/systohc.c index ef3c07a52c3a..7728d5e32bf4 100644 --- a/drivers/rtc/systohc.c +++ b/drivers/rtc/systohc.c | |||
| @@ -35,7 +35,10 @@ int rtc_set_ntp_time(struct timespec64 now) | |||
| 35 | if (rtc) { | 35 | if (rtc) { |
| 36 | /* rtc_hctosys exclusively uses UTC, so we call set_time here, | 36 | /* rtc_hctosys exclusively uses UTC, so we call set_time here, |
| 37 | * not set_mmss. */ | 37 | * not set_mmss. */ |
| 38 | if (rtc->ops && (rtc->ops->set_time || rtc->ops->set_mmss)) | 38 | if (rtc->ops && |
| 39 | (rtc->ops->set_time || | ||
| 40 | rtc->ops->set_mmss64 || | ||
| 41 | rtc->ops->set_mmss)) | ||
| 39 | err = rtc_set_time(rtc, &tm); | 42 | err = rtc_set_time(rtc, &tm); |
| 40 | rtc_class_close(rtc); | 43 | rtc_class_close(rtc); |
| 41 | } | 44 | } |
