diff options
| author | Xunlei Pang <[email protected]> | 2015-04-02 03:34:27 +0000 |
|---|---|---|
| committer | Ingo Molnar <[email protected]> | 2015-04-03 06:18:24 +0000 |
| commit | 8e4ff1a81aa91d12856287c7103d0301ac91351a (patch) | |
| tree | cf42bb0295c0e6accd4453645573fa625c3e64ce /drivers/rtc/interface.c | |
| parent | ARM, clocksource/drivers: Provide read_boot_clock64() and read_persistent_clo... (diff) | |
| download | kernel-8e4ff1a81aa91d12856287c7103d0301ac91351a.tar.gz kernel-8e4ff1a81aa91d12856287c7103d0301ac91351a.zip | |
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 <[email protected]>
[jstultz: Add whitespace fix for checkpatch]
Signed-off-by: John Stultz <[email protected]>
Acked-by: Alessandro Zummo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
Diffstat (limited to 'drivers/rtc/interface.c')
| -rw-r--r-- | drivers/rtc/interface.c | 8 |
1 files changed, 7 insertions, 1 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) err = -ENODEV; else if (rtc->ops->set_time) err = rtc->ops->set_time(rtc->dev.parent, tm); - else if (rtc->ops->set_mmss) { + else if (rtc->ops->set_mmss64) { + time64_t secs64 = rtc_tm_to_time64(tm); + + err = rtc->ops->set_mmss64(rtc->dev.parent, secs64); + } else if (rtc->ops->set_mmss) { time64_t secs64 = rtc_tm_to_time64(tm); err = rtc->ops->set_mmss(rtc->dev.parent, secs64); } else @@ -96,6 +100,8 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs) if (!rtc->ops) err = -ENODEV; + else if (rtc->ops->set_mmss64) + err = rtc->ops->set_mmss64(rtc->dev.parent, secs); else if (rtc->ops->set_mmss) err = rtc->ops->set_mmss(rtc->dev.parent, secs); else if (rtc->ops->read_time && rtc->ops->set_time) { |
