diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-10 11:18:32 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-10 11:18:32 -0500 |
commit | a157508c9790ccd1c8b5c6a828d6ba85bbe95aaa (patch) | |
tree | 84fc815aac23bb44747e5bdad0559e7383d6f1e6 /drivers/rtc | |
parent | 86c6a2fddf0b89b494c7616f2c06cf915c4bff01 (diff) | |
parent | 89de77a8c557f14d2713a1f43fbc33980e639b98 (diff) |
Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer core updates from Thomas Gleixner:
"The time(r) departement provides:
- more infrastructure work on the year 2038 issue
- a few fixes in the Armada SoC timers
- the usual pile of fixlets and improvements"
* 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
clocksource: armada-370-xp: Use the reference clock on A375 SoC
watchdog: orion: Use the reference clock on Armada 375 SoC
clocksource: armada-370-xp: Add missing clock enable
time: Fix sign bug in NTP mult overflow warning
time: Remove timekeeping_inject_sleeptime()
rtc: Update suspend/resume timing to use 64bit time
rtc/lib: Provide y2038 safe rtc_tm_to_time()/rtc_time_to_tm() replacement
time: Fixup comments to reflect usage of timespec64
time: Expose get_monotonic_coarse64() for in-kernel uses
time: Expose getrawmonotonic64 for in-kernel uses
time: Provide y2038 safe mktime() replacement
time: Provide y2038 safe timekeeping_inject_sleeptime() replacement
time: Provide y2038 safe do_settimeofday() replacement
time: Complete NTP adjustment threshold judging conditions
time: Avoid possible NTP adjustment mult overflow.
time: Rename udelay_test.c to test_udelay.c
clocksource: sirf: Remove hard-coded clock rate
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/class.c | 30 | ||||
-rw-r--r-- | drivers/rtc/rtc-lib.c | 38 |
2 files changed, 35 insertions, 33 deletions
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 38e26be705be..472a5adc4642 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c | |||
@@ -45,14 +45,14 @@ int rtc_hctosys_ret = -ENODEV; | |||
45 | * system's wall clock; restore it on resume(). | 45 | * system's wall clock; restore it on resume(). |
46 | */ | 46 | */ |
47 | 47 | ||
48 | static struct timespec old_rtc, old_system, old_delta; | 48 | static struct timespec64 old_rtc, old_system, old_delta; |
49 | 49 | ||
50 | 50 | ||
51 | static int rtc_suspend(struct device *dev) | 51 | static int rtc_suspend(struct device *dev) |
52 | { | 52 | { |
53 | struct rtc_device *rtc = to_rtc_device(dev); | 53 | struct rtc_device *rtc = to_rtc_device(dev); |
54 | struct rtc_time tm; | 54 | struct rtc_time tm; |
55 | struct timespec delta, delta_delta; | 55 | struct timespec64 delta, delta_delta; |
56 | int err; | 56 | int err; |
57 | 57 | ||
58 | if (has_persistent_clock()) | 58 | if (has_persistent_clock()) |
@@ -68,8 +68,8 @@ static int rtc_suspend(struct device *dev) | |||
68 | return 0; | 68 | return 0; |
69 | } | 69 | } |
70 | 70 | ||
71 | getnstimeofday(&old_system); | 71 | getnstimeofday64(&old_system); |
72 | rtc_tm_to_time(&tm, &old_rtc.tv_sec); | 72 | old_rtc.tv_sec = rtc_tm_to_time64(&tm); |
73 | 73 | ||
74 | 74 | ||
75 | /* | 75 | /* |
@@ -78,8 +78,8 @@ static int rtc_suspend(struct device *dev) | |||
78 | * try to compensate so the difference in system time | 78 | * try to compensate so the difference in system time |
79 | * and rtc time stays close to constant. | 79 | * and rtc time stays close to constant. |
80 | */ | 80 | */ |
81 | delta = timespec_sub(old_system, old_rtc); | 81 | delta = timespec64_sub(old_system, old_rtc); |
82 | delta_delta = timespec_sub(delta, old_delta); | 82 | delta_delta = timespec64_sub(delta, old_delta); |
83 | if (delta_delta.tv_sec < -2 || delta_delta.tv_sec >= 2) { | 83 | if (delta_delta.tv_sec < -2 || delta_delta.tv_sec >= 2) { |
84 | /* | 84 | /* |
85 | * if delta_delta is too large, assume time correction | 85 | * if delta_delta is too large, assume time correction |
@@ -88,7 +88,7 @@ static int rtc_suspend(struct device *dev) | |||
88 | old_delta = delta; | 88 | old_delta = delta; |
89 | } else { | 89 | } else { |
90 | /* Otherwise try to adjust old_system to compensate */ | 90 | /* Otherwise try to adjust old_system to compensate */ |
91 | old_system = timespec_sub(old_system, delta_delta); | 91 | old_system = timespec64_sub(old_system, delta_delta); |
92 | } | 92 | } |
93 | 93 | ||
94 | return 0; | 94 | return 0; |
@@ -98,8 +98,8 @@ static int rtc_resume(struct device *dev) | |||
98 | { | 98 | { |
99 | struct rtc_device *rtc = to_rtc_device(dev); | 99 | struct rtc_device *rtc = to_rtc_device(dev); |
100 | struct rtc_time tm; | 100 | struct rtc_time tm; |
101 | struct timespec new_system, new_rtc; | 101 | struct timespec64 new_system, new_rtc; |
102 | struct timespec sleep_time; | 102 | struct timespec64 sleep_time; |
103 | int err; | 103 | int err; |
104 | 104 | ||
105 | if (has_persistent_clock()) | 105 | if (has_persistent_clock()) |
@@ -110,7 +110,7 @@ static int rtc_resume(struct device *dev) | |||
110 | return 0; | 110 | return 0; |
111 | 111 | ||
112 | /* snapshot the current rtc and system time at resume */ | 112 | /* snapshot the current rtc and system time at resume */ |
113 | getnstimeofday(&new_system); | 113 | getnstimeofday64(&new_system); |
114 | err = rtc_read_time(rtc, &tm); | 114 | err = rtc_read_time(rtc, &tm); |
115 | if (err < 0) { | 115 | if (err < 0) { |
116 | pr_debug("%s: fail to read rtc time\n", dev_name(&rtc->dev)); | 116 | pr_debug("%s: fail to read rtc time\n", dev_name(&rtc->dev)); |
@@ -121,7 +121,7 @@ static int rtc_resume(struct device *dev) | |||
121 | pr_debug("%s: bogus resume time\n", dev_name(&rtc->dev)); | 121 | pr_debug("%s: bogus resume time\n", dev_name(&rtc->dev)); |
122 | return 0; | 122 | return 0; |
123 | } | 123 | } |
124 | rtc_tm_to_time(&tm, &new_rtc.tv_sec); | 124 | new_rtc.tv_sec = rtc_tm_to_time64(&tm); |
125 | new_rtc.tv_nsec = 0; | 125 | new_rtc.tv_nsec = 0; |
126 | 126 | ||
127 | if (new_rtc.tv_sec < old_rtc.tv_sec) { | 127 | if (new_rtc.tv_sec < old_rtc.tv_sec) { |
@@ -130,7 +130,7 @@ static int rtc_resume(struct device *dev) | |||
130 | } | 130 | } |
131 | 131 | ||
132 | /* calculate the RTC time delta (sleep time)*/ | 132 | /* calculate the RTC time delta (sleep time)*/ |
133 | sleep_time = timespec_sub(new_rtc, old_rtc); | 133 | sleep_time = timespec64_sub(new_rtc, old_rtc); |
134 | 134 | ||
135 | /* | 135 | /* |
136 | * Since these RTC suspend/resume handlers are not called | 136 | * Since these RTC suspend/resume handlers are not called |
@@ -139,11 +139,11 @@ static int rtc_resume(struct device *dev) | |||
139 | * so subtract kernel run-time between rtc_suspend to rtc_resume | 139 | * so subtract kernel run-time between rtc_suspend to rtc_resume |
140 | * to keep things accurate. | 140 | * to keep things accurate. |
141 | */ | 141 | */ |
142 | sleep_time = timespec_sub(sleep_time, | 142 | sleep_time = timespec64_sub(sleep_time, |
143 | timespec_sub(new_system, old_system)); | 143 | timespec64_sub(new_system, old_system)); |
144 | 144 | ||
145 | if (sleep_time.tv_sec >= 0) | 145 | if (sleep_time.tv_sec >= 0) |
146 | timekeeping_inject_sleeptime(&sleep_time); | 146 | timekeeping_inject_sleeptime64(&sleep_time); |
147 | rtc_hctosys_ret = 0; | 147 | rtc_hctosys_ret = 0; |
148 | return 0; | 148 | return 0; |
149 | } | 149 | } |
diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c index c4cf05731118..e6bfb9c42a10 100644 --- a/drivers/rtc/rtc-lib.c +++ b/drivers/rtc/rtc-lib.c | |||
@@ -45,16 +45,20 @@ int rtc_year_days(unsigned int day, unsigned int month, unsigned int year) | |||
45 | } | 45 | } |
46 | EXPORT_SYMBOL(rtc_year_days); | 46 | EXPORT_SYMBOL(rtc_year_days); |
47 | 47 | ||
48 | |||
48 | /* | 49 | /* |
50 | * rtc_time_to_tm64 - Converts time64_t to rtc_time. | ||
49 | * Convert seconds since 01-01-1970 00:00:00 to Gregorian date. | 51 | * Convert seconds since 01-01-1970 00:00:00 to Gregorian date. |
50 | */ | 52 | */ |
51 | void rtc_time_to_tm(unsigned long time, struct rtc_time *tm) | 53 | void rtc_time64_to_tm(time64_t time, struct rtc_time *tm) |
52 | { | 54 | { |
53 | unsigned int month, year; | 55 | unsigned int month, year; |
56 | unsigned long secs; | ||
54 | int days; | 57 | int days; |
55 | 58 | ||
56 | days = time / 86400; | 59 | /* time must be positive */ |
57 | time -= (unsigned int) days * 86400; | 60 | days = div_s64(time, 86400); |
61 | secs = time - (unsigned int) days * 86400; | ||
58 | 62 | ||
59 | /* day of the week, 1970-01-01 was a Thursday */ | 63 | /* day of the week, 1970-01-01 was a Thursday */ |
60 | tm->tm_wday = (days + 4) % 7; | 64 | tm->tm_wday = (days + 4) % 7; |
@@ -81,14 +85,14 @@ void rtc_time_to_tm(unsigned long time, struct rtc_time *tm) | |||
81 | tm->tm_mon = month; | 85 | tm->tm_mon = month; |
82 | tm->tm_mday = days + 1; | 86 | tm->tm_mday = days + 1; |
83 | 87 | ||
84 | tm->tm_hour = time / 3600; | 88 | tm->tm_hour = secs / 3600; |
85 | time -= tm->tm_hour * 3600; | 89 | secs -= tm->tm_hour * 3600; |
86 | tm->tm_min = time / 60; | 90 | tm->tm_min = secs / 60; |
87 | tm->tm_sec = time - tm->tm_min * 60; | 91 | tm->tm_sec = secs - tm->tm_min * 60; |
88 | 92 | ||
89 | tm->tm_isdst = 0; | 93 | tm->tm_isdst = 0; |
90 | } | 94 | } |
91 | EXPORT_SYMBOL(rtc_time_to_tm); | 95 | EXPORT_SYMBOL(rtc_time64_to_tm); |
92 | 96 | ||
93 | /* | 97 | /* |
94 | * Does the rtc_time represent a valid date/time? | 98 | * Does the rtc_time represent a valid date/time? |
@@ -109,24 +113,22 @@ int rtc_valid_tm(struct rtc_time *tm) | |||
109 | EXPORT_SYMBOL(rtc_valid_tm); | 113 | EXPORT_SYMBOL(rtc_valid_tm); |
110 | 114 | ||
111 | /* | 115 | /* |
116 | * rtc_tm_to_time64 - Converts rtc_time to time64_t. | ||
112 | * Convert Gregorian date to seconds since 01-01-1970 00:00:00. | 117 | * Convert Gregorian date to seconds since 01-01-1970 00:00:00. |
113 | */ | 118 | */ |
114 | int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time) | 119 | time64_t rtc_tm_to_time64(struct rtc_time *tm) |
115 | { | 120 | { |
116 | *time = mktime(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, | 121 | return mktime64(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, |
117 | tm->tm_hour, tm->tm_min, tm->tm_sec); | 122 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
118 | return 0; | ||
119 | } | 123 | } |
120 | EXPORT_SYMBOL(rtc_tm_to_time); | 124 | EXPORT_SYMBOL(rtc_tm_to_time64); |
121 | 125 | ||
122 | /* | 126 | /* |
123 | * Convert rtc_time to ktime | 127 | * Convert rtc_time to ktime |
124 | */ | 128 | */ |
125 | ktime_t rtc_tm_to_ktime(struct rtc_time tm) | 129 | ktime_t rtc_tm_to_ktime(struct rtc_time tm) |
126 | { | 130 | { |
127 | time_t time; | 131 | return ktime_set(rtc_tm_to_time64(&tm), 0); |
128 | rtc_tm_to_time(&tm, &time); | ||
129 | return ktime_set(time, 0); | ||
130 | } | 132 | } |
131 | EXPORT_SYMBOL_GPL(rtc_tm_to_ktime); | 133 | EXPORT_SYMBOL_GPL(rtc_tm_to_ktime); |
132 | 134 | ||
@@ -135,14 +137,14 @@ EXPORT_SYMBOL_GPL(rtc_tm_to_ktime); | |||
135 | */ | 137 | */ |
136 | struct rtc_time rtc_ktime_to_tm(ktime_t kt) | 138 | struct rtc_time rtc_ktime_to_tm(ktime_t kt) |
137 | { | 139 | { |
138 | struct timespec ts; | 140 | struct timespec64 ts; |
139 | struct rtc_time ret; | 141 | struct rtc_time ret; |
140 | 142 | ||
141 | ts = ktime_to_timespec(kt); | 143 | ts = ktime_to_timespec64(kt); |
142 | /* Round up any ns */ | 144 | /* Round up any ns */ |
143 | if (ts.tv_nsec) | 145 | if (ts.tv_nsec) |
144 | ts.tv_sec++; | 146 | ts.tv_sec++; |
145 | rtc_time_to_tm(ts.tv_sec, &ret); | 147 | rtc_time64_to_tm(ts.tv_sec, &ret); |
146 | return ret; | 148 | return ret; |
147 | } | 149 | } |
148 | EXPORT_SYMBOL_GPL(rtc_ktime_to_tm); | 150 | EXPORT_SYMBOL_GPL(rtc_ktime_to_tm); |