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 | |
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
-rw-r--r-- | Documentation/devicetree/bindings/timer/marvell,armada-370-xp-timer.txt | 9 | ||||
-rw-r--r-- | Documentation/devicetree/bindings/watchdog/marvel.txt | 13 | ||||
-rw-r--r-- | drivers/clocksource/time-armada-370-xp.c | 30 | ||||
-rw-r--r-- | drivers/clocksource/timer-marco.c | 23 | ||||
-rw-r--r-- | drivers/rtc/class.c | 30 | ||||
-rw-r--r-- | drivers/rtc/rtc-lib.c | 38 | ||||
-rw-r--r-- | drivers/watchdog/orion_wdt.c | 42 | ||||
-rw-r--r-- | include/linux/rtc.h | 21 | ||||
-rw-r--r-- | include/linux/time.h | 17 | ||||
-rw-r--r-- | include/linux/timekeeping.h | 49 | ||||
-rw-r--r-- | kernel/time/Makefile | 2 | ||||
-rw-r--r-- | kernel/time/test_udelay.c (renamed from kernel/time/udelay_test.c) | 0 | ||||
-rw-r--r-- | kernel/time/time.c | 20 | ||||
-rw-r--r-- | kernel/time/timekeeping.c | 59 |
14 files changed, 253 insertions, 100 deletions
diff --git a/Documentation/devicetree/bindings/timer/marvell,armada-370-xp-timer.txt b/Documentation/devicetree/bindings/timer/marvell,armada-370-xp-timer.txt index f455182b1086..e9c78ce880e6 100644 --- a/Documentation/devicetree/bindings/timer/marvell,armada-370-xp-timer.txt +++ b/Documentation/devicetree/bindings/timer/marvell,armada-370-xp-timer.txt | |||
@@ -2,8 +2,10 @@ Marvell Armada 370 and Armada XP Timers | |||
2 | --------------------------------------- | 2 | --------------------------------------- |
3 | 3 | ||
4 | Required properties: | 4 | Required properties: |
5 | - compatible: Should be either "marvell,armada-370-timer" or | 5 | - compatible: Should be one of the following |
6 | "marvell,armada-xp-timer" as appropriate. | 6 | "marvell,armada-370-timer", |
7 | "marvell,armada-375-timer", | ||
8 | "marvell,armada-xp-timer". | ||
7 | - interrupts: Should contain the list of Global Timer interrupts and | 9 | - interrupts: Should contain the list of Global Timer interrupts and |
8 | then local timer interrupts | 10 | then local timer interrupts |
9 | - reg: Should contain location and length for timers register. First | 11 | - reg: Should contain location and length for timers register. First |
@@ -13,7 +15,8 @@ Required properties: | |||
13 | Clocks required for compatible = "marvell,armada-370-timer": | 15 | Clocks required for compatible = "marvell,armada-370-timer": |
14 | - clocks : Must contain a single entry describing the clock input | 16 | - clocks : Must contain a single entry describing the clock input |
15 | 17 | ||
16 | Clocks required for compatible = "marvell,armada-xp-timer": | 18 | Clocks required for compatibles = "marvell,armada-xp-timer", |
19 | "marvell,armada-375-timer": | ||
17 | - clocks : Must contain an entry for each entry in clock-names. | 20 | - clocks : Must contain an entry for each entry in clock-names. |
18 | - clock-names : Must include the following entries: | 21 | - clock-names : Must include the following entries: |
19 | "nbclk" (L2/coherency fabric clock), | 22 | "nbclk" (L2/coherency fabric clock), |
diff --git a/Documentation/devicetree/bindings/watchdog/marvel.txt b/Documentation/devicetree/bindings/watchdog/marvel.txt index 97223fddb7bd..858ed9221ac4 100644 --- a/Documentation/devicetree/bindings/watchdog/marvel.txt +++ b/Documentation/devicetree/bindings/watchdog/marvel.txt | |||
@@ -17,6 +17,18 @@ For "marvell,armada-375-wdt" and "marvell,armada-380-wdt": | |||
17 | - reg : A third entry is mandatory and should contain the | 17 | - reg : A third entry is mandatory and should contain the |
18 | shared mask/unmask RSTOUT address. | 18 | shared mask/unmask RSTOUT address. |
19 | 19 | ||
20 | Clocks required for compatibles = "marvell,orion-wdt", | ||
21 | "marvell,armada-370-wdt": | ||
22 | - clocks : Must contain a single entry describing the clock input | ||
23 | |||
24 | Clocks required for compatibles = "marvell,armada-xp-wdt" | ||
25 | "marvell,armada-375-wdt" | ||
26 | "marvell,armada-380-wdt": | ||
27 | - clocks : Must contain an entry for each entry in clock-names. | ||
28 | - clock-names : Must include the following entries: | ||
29 | "nbclk" (L2/coherency fabric clock), | ||
30 | "fixed" (Reference 25 MHz fixed-clock). | ||
31 | |||
20 | Optional properties: | 32 | Optional properties: |
21 | 33 | ||
22 | - interrupts : Contains the IRQ for watchdog expiration | 34 | - interrupts : Contains the IRQ for watchdog expiration |
@@ -30,4 +42,5 @@ Example: | |||
30 | interrupts = <3>; | 42 | interrupts = <3>; |
31 | timeout-sec = <10>; | 43 | timeout-sec = <10>; |
32 | status = "okay"; | 44 | status = "okay"; |
45 | clocks = <&gate_clk 7>; | ||
33 | }; | 46 | }; |
diff --git a/drivers/clocksource/time-armada-370-xp.c b/drivers/clocksource/time-armada-370-xp.c index ff37d3abb806..0c8c5e337540 100644 --- a/drivers/clocksource/time-armada-370-xp.c +++ b/drivers/clocksource/time-armada-370-xp.c | |||
@@ -318,6 +318,7 @@ static void __init armada_xp_timer_init(struct device_node *np) | |||
318 | 318 | ||
319 | /* The 25Mhz fixed clock is mandatory, and must always be available */ | 319 | /* The 25Mhz fixed clock is mandatory, and must always be available */ |
320 | BUG_ON(IS_ERR(clk)); | 320 | BUG_ON(IS_ERR(clk)); |
321 | clk_prepare_enable(clk); | ||
321 | timer_clk = clk_get_rate(clk); | 322 | timer_clk = clk_get_rate(clk); |
322 | 323 | ||
323 | armada_370_xp_timer_common_init(np); | 324 | armada_370_xp_timer_common_init(np); |
@@ -325,11 +326,40 @@ static void __init armada_xp_timer_init(struct device_node *np) | |||
325 | CLOCKSOURCE_OF_DECLARE(armada_xp, "marvell,armada-xp-timer", | 326 | CLOCKSOURCE_OF_DECLARE(armada_xp, "marvell,armada-xp-timer", |
326 | armada_xp_timer_init); | 327 | armada_xp_timer_init); |
327 | 328 | ||
329 | static void __init armada_375_timer_init(struct device_node *np) | ||
330 | { | ||
331 | struct clk *clk; | ||
332 | |||
333 | clk = of_clk_get_by_name(np, "fixed"); | ||
334 | if (!IS_ERR(clk)) { | ||
335 | clk_prepare_enable(clk); | ||
336 | timer_clk = clk_get_rate(clk); | ||
337 | } else { | ||
338 | |||
339 | /* | ||
340 | * This fallback is required in order to retain proper | ||
341 | * devicetree backwards compatibility. | ||
342 | */ | ||
343 | clk = of_clk_get(np, 0); | ||
344 | |||
345 | /* Must have at least a clock */ | ||
346 | BUG_ON(IS_ERR(clk)); | ||
347 | clk_prepare_enable(clk); | ||
348 | timer_clk = clk_get_rate(clk) / TIMER_DIVIDER; | ||
349 | timer25Mhz = false; | ||
350 | } | ||
351 | |||
352 | armada_370_xp_timer_common_init(np); | ||
353 | } | ||
354 | CLOCKSOURCE_OF_DECLARE(armada_375, "marvell,armada-375-timer", | ||
355 | armada_375_timer_init); | ||
356 | |||
328 | static void __init armada_370_timer_init(struct device_node *np) | 357 | static void __init armada_370_timer_init(struct device_node *np) |
329 | { | 358 | { |
330 | struct clk *clk = of_clk_get(np, 0); | 359 | struct clk *clk = of_clk_get(np, 0); |
331 | 360 | ||
332 | BUG_ON(IS_ERR(clk)); | 361 | BUG_ON(IS_ERR(clk)); |
362 | clk_prepare_enable(clk); | ||
333 | timer_clk = clk_get_rate(clk) / TIMER_DIVIDER; | 363 | timer_clk = clk_get_rate(clk) / TIMER_DIVIDER; |
334 | timer25Mhz = false; | 364 | timer25Mhz = false; |
335 | 365 | ||
diff --git a/drivers/clocksource/timer-marco.c b/drivers/clocksource/timer-marco.c index caf7a2030461..361a789d4bee 100644 --- a/drivers/clocksource/timer-marco.c +++ b/drivers/clocksource/timer-marco.c | |||
@@ -20,8 +20,6 @@ | |||
20 | #include <linux/of_address.h> | 20 | #include <linux/of_address.h> |
21 | #include <linux/sched_clock.h> | 21 | #include <linux/sched_clock.h> |
22 | 22 | ||
23 | #define MARCO_CLOCK_FREQ 1000000 | ||
24 | |||
25 | #define SIRFSOC_TIMER_32COUNTER_0_CTRL 0x0000 | 23 | #define SIRFSOC_TIMER_32COUNTER_0_CTRL 0x0000 |
26 | #define SIRFSOC_TIMER_32COUNTER_1_CTRL 0x0004 | 24 | #define SIRFSOC_TIMER_32COUNTER_1_CTRL 0x0004 |
27 | #define SIRFSOC_TIMER_MATCH_0 0x0018 | 25 | #define SIRFSOC_TIMER_MATCH_0 0x0018 |
@@ -40,6 +38,8 @@ | |||
40 | 38 | ||
41 | #define SIRFSOC_TIMER_REG_CNT 6 | 39 | #define SIRFSOC_TIMER_REG_CNT 6 |
42 | 40 | ||
41 | static unsigned long marco_timer_rate; | ||
42 | |||
43 | static const u32 sirfsoc_timer_reg_list[SIRFSOC_TIMER_REG_CNT] = { | 43 | static const u32 sirfsoc_timer_reg_list[SIRFSOC_TIMER_REG_CNT] = { |
44 | SIRFSOC_TIMER_WATCHDOG_EN, | 44 | SIRFSOC_TIMER_WATCHDOG_EN, |
45 | SIRFSOC_TIMER_32COUNTER_0_CTRL, | 45 | SIRFSOC_TIMER_32COUNTER_0_CTRL, |
@@ -195,7 +195,7 @@ static int sirfsoc_local_timer_setup(struct clock_event_device *ce) | |||
195 | ce->rating = 200; | 195 | ce->rating = 200; |
196 | ce->set_mode = sirfsoc_timer_set_mode; | 196 | ce->set_mode = sirfsoc_timer_set_mode; |
197 | ce->set_next_event = sirfsoc_timer_set_next_event; | 197 | ce->set_next_event = sirfsoc_timer_set_next_event; |
198 | clockevents_calc_mult_shift(ce, MARCO_CLOCK_FREQ, 60); | 198 | clockevents_calc_mult_shift(ce, marco_timer_rate, 60); |
199 | ce->max_delta_ns = clockevent_delta2ns(-2, ce); | 199 | ce->max_delta_ns = clockevent_delta2ns(-2, ce); |
200 | ce->min_delta_ns = clockevent_delta2ns(2, ce); | 200 | ce->min_delta_ns = clockevent_delta2ns(2, ce); |
201 | ce->cpumask = cpumask_of(cpu); | 201 | ce->cpumask = cpumask_of(cpu); |
@@ -257,7 +257,6 @@ static void __init sirfsoc_clockevent_init(void) | |||
257 | /* initialize the kernel jiffy timer source */ | 257 | /* initialize the kernel jiffy timer source */ |
258 | static void __init sirfsoc_marco_timer_init(struct device_node *np) | 258 | static void __init sirfsoc_marco_timer_init(struct device_node *np) |
259 | { | 259 | { |
260 | unsigned long rate; | ||
261 | u32 timer_div; | 260 | u32 timer_div; |
262 | struct clk *clk; | 261 | struct clk *clk; |
263 | 262 | ||
@@ -266,16 +265,12 @@ static void __init sirfsoc_marco_timer_init(struct device_node *np) | |||
266 | 265 | ||
267 | BUG_ON(clk_prepare_enable(clk)); | 266 | BUG_ON(clk_prepare_enable(clk)); |
268 | 267 | ||
269 | rate = clk_get_rate(clk); | 268 | marco_timer_rate = clk_get_rate(clk); |
270 | |||
271 | BUG_ON(rate < MARCO_CLOCK_FREQ); | ||
272 | BUG_ON(rate % MARCO_CLOCK_FREQ); | ||
273 | 269 | ||
274 | /* Initialize the timer dividers */ | 270 | /* timer dividers: 0, not divided */ |
275 | timer_div = rate / MARCO_CLOCK_FREQ - 1; | 271 | writel_relaxed(0, sirfsoc_timer_base + SIRFSOC_TIMER_64COUNTER_CTRL); |
276 | writel_relaxed(timer_div << 16, sirfsoc_timer_base + SIRFSOC_TIMER_64COUNTER_CTRL); | 272 | writel_relaxed(0, sirfsoc_timer_base + SIRFSOC_TIMER_32COUNTER_0_CTRL); |
277 | writel_relaxed(timer_div << 16, sirfsoc_timer_base + SIRFSOC_TIMER_32COUNTER_0_CTRL); | 273 | writel_relaxed(0, sirfsoc_timer_base + SIRFSOC_TIMER_32COUNTER_1_CTRL); |
278 | writel_relaxed(timer_div << 16, sirfsoc_timer_base + SIRFSOC_TIMER_32COUNTER_1_CTRL); | ||
279 | 274 | ||
280 | /* Initialize timer counters to 0 */ | 275 | /* Initialize timer counters to 0 */ |
281 | writel_relaxed(0, sirfsoc_timer_base + SIRFSOC_TIMER_64COUNTER_LOAD_LO); | 276 | writel_relaxed(0, sirfsoc_timer_base + SIRFSOC_TIMER_64COUNTER_LOAD_LO); |
@@ -288,7 +283,7 @@ static void __init sirfsoc_marco_timer_init(struct device_node *np) | |||
288 | /* Clear all interrupts */ | 283 | /* Clear all interrupts */ |
289 | writel_relaxed(0xFFFF, sirfsoc_timer_base + SIRFSOC_TIMER_INTR_STATUS); | 284 | writel_relaxed(0xFFFF, sirfsoc_timer_base + SIRFSOC_TIMER_INTR_STATUS); |
290 | 285 | ||
291 | BUG_ON(clocksource_register_hz(&sirfsoc_clocksource, MARCO_CLOCK_FREQ)); | 286 | BUG_ON(clocksource_register_hz(&sirfsoc_clocksource, marco_timer_rate)); |
292 | 287 | ||
293 | sirfsoc_clockevent_init(); | 288 | sirfsoc_clockevent_init(); |
294 | } | 289 | } |
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); |
diff --git a/drivers/watchdog/orion_wdt.c b/drivers/watchdog/orion_wdt.c index 00d0741228fc..8cb1ff3bcd90 100644 --- a/drivers/watchdog/orion_wdt.c +++ b/drivers/watchdog/orion_wdt.c | |||
@@ -114,6 +114,46 @@ static int armada370_wdt_clock_init(struct platform_device *pdev, | |||
114 | return 0; | 114 | return 0; |
115 | } | 115 | } |
116 | 116 | ||
117 | static int armada375_wdt_clock_init(struct platform_device *pdev, | ||
118 | struct orion_watchdog *dev) | ||
119 | { | ||
120 | int ret; | ||
121 | |||
122 | dev->clk = of_clk_get_by_name(pdev->dev.of_node, "fixed"); | ||
123 | if (!IS_ERR(dev->clk)) { | ||
124 | ret = clk_prepare_enable(dev->clk); | ||
125 | if (ret) { | ||
126 | clk_put(dev->clk); | ||
127 | return ret; | ||
128 | } | ||
129 | |||
130 | atomic_io_modify(dev->reg + TIMER_CTRL, | ||
131 | WDT_AXP_FIXED_ENABLE_BIT, | ||
132 | WDT_AXP_FIXED_ENABLE_BIT); | ||
133 | dev->clk_rate = clk_get_rate(dev->clk); | ||
134 | |||
135 | return 0; | ||
136 | } | ||
137 | |||
138 | /* Mandatory fallback for proper devicetree backward compatibility */ | ||
139 | dev->clk = clk_get(&pdev->dev, NULL); | ||
140 | if (IS_ERR(dev->clk)) | ||
141 | return PTR_ERR(dev->clk); | ||
142 | |||
143 | ret = clk_prepare_enable(dev->clk); | ||
144 | if (ret) { | ||
145 | clk_put(dev->clk); | ||
146 | return ret; | ||
147 | } | ||
148 | |||
149 | atomic_io_modify(dev->reg + TIMER_CTRL, | ||
150 | WDT_A370_RATIO_MASK(WDT_A370_RATIO_SHIFT), | ||
151 | WDT_A370_RATIO_MASK(WDT_A370_RATIO_SHIFT)); | ||
152 | dev->clk_rate = clk_get_rate(dev->clk) / WDT_A370_RATIO; | ||
153 | |||
154 | return 0; | ||
155 | } | ||
156 | |||
117 | static int armadaxp_wdt_clock_init(struct platform_device *pdev, | 157 | static int armadaxp_wdt_clock_init(struct platform_device *pdev, |
118 | struct orion_watchdog *dev) | 158 | struct orion_watchdog *dev) |
119 | { | 159 | { |
@@ -394,7 +434,7 @@ static const struct orion_watchdog_data armada375_data = { | |||
394 | .rstout_mask_bit = BIT(10), | 434 | .rstout_mask_bit = BIT(10), |
395 | .wdt_enable_bit = BIT(8), | 435 | .wdt_enable_bit = BIT(8), |
396 | .wdt_counter_offset = 0x34, | 436 | .wdt_counter_offset = 0x34, |
397 | .clock_init = armada370_wdt_clock_init, | 437 | .clock_init = armada375_wdt_clock_init, |
398 | .enabled = armada375_enabled, | 438 | .enabled = armada375_enabled, |
399 | .start = armada375_start, | 439 | .start = armada375_start, |
400 | .stop = armada375_stop, | 440 | .stop = armada375_stop, |
diff --git a/include/linux/rtc.h b/include/linux/rtc.h index c2c28975293c..6d6be09a2fe5 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h | |||
@@ -19,11 +19,28 @@ | |||
19 | extern int rtc_month_days(unsigned int month, unsigned int year); | 19 | extern int rtc_month_days(unsigned int month, unsigned int year); |
20 | extern int rtc_year_days(unsigned int day, unsigned int month, unsigned int year); | 20 | extern int rtc_year_days(unsigned int day, unsigned int month, unsigned int year); |
21 | extern int rtc_valid_tm(struct rtc_time *tm); | 21 | extern int rtc_valid_tm(struct rtc_time *tm); |
22 | extern int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time); | 22 | extern time64_t rtc_tm_to_time64(struct rtc_time *tm); |
23 | extern void rtc_time_to_tm(unsigned long time, struct rtc_time *tm); | 23 | extern void rtc_time64_to_tm(time64_t time, struct rtc_time *tm); |
24 | ktime_t rtc_tm_to_ktime(struct rtc_time tm); | 24 | ktime_t rtc_tm_to_ktime(struct rtc_time tm); |
25 | struct rtc_time rtc_ktime_to_tm(ktime_t kt); | 25 | struct rtc_time rtc_ktime_to_tm(ktime_t kt); |
26 | 26 | ||
27 | /** | ||
28 | * Deprecated. Use rtc_time64_to_tm(). | ||
29 | */ | ||
30 | static inline void rtc_time_to_tm(unsigned long time, struct rtc_time *tm) | ||
31 | { | ||
32 | rtc_time64_to_tm(time, tm); | ||
33 | } | ||
34 | |||
35 | /** | ||
36 | * Deprecated. Use rtc_tm_to_time64(). | ||
37 | */ | ||
38 | static inline int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time) | ||
39 | { | ||
40 | *time = rtc_tm_to_time64(tm); | ||
41 | |||
42 | return 0; | ||
43 | } | ||
27 | 44 | ||
28 | #include <linux/device.h> | 45 | #include <linux/device.h> |
29 | #include <linux/seq_file.h> | 46 | #include <linux/seq_file.h> |
diff --git a/include/linux/time.h b/include/linux/time.h index 8c42cf8d2444..203c2ad40d71 100644 --- a/include/linux/time.h +++ b/include/linux/time.h | |||
@@ -39,9 +39,20 @@ static inline int timeval_compare(const struct timeval *lhs, const struct timeva | |||
39 | return lhs->tv_usec - rhs->tv_usec; | 39 | return lhs->tv_usec - rhs->tv_usec; |
40 | } | 40 | } |
41 | 41 | ||
42 | extern unsigned long mktime(const unsigned int year, const unsigned int mon, | 42 | extern time64_t mktime64(const unsigned int year, const unsigned int mon, |
43 | const unsigned int day, const unsigned int hour, | 43 | const unsigned int day, const unsigned int hour, |
44 | const unsigned int min, const unsigned int sec); | 44 | const unsigned int min, const unsigned int sec); |
45 | |||
46 | /** | ||
47 | * Deprecated. Use mktime64(). | ||
48 | */ | ||
49 | static inline unsigned long mktime(const unsigned int year, | ||
50 | const unsigned int mon, const unsigned int day, | ||
51 | const unsigned int hour, const unsigned int min, | ||
52 | const unsigned int sec) | ||
53 | { | ||
54 | return mktime64(year, mon, day, hour, min, sec); | ||
55 | } | ||
45 | 56 | ||
46 | extern void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec); | 57 | extern void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec); |
47 | 58 | ||
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 1caa6b04fdc5..961fea373f83 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h | |||
@@ -10,7 +10,7 @@ extern int timekeeping_suspended; | |||
10 | * Get and set timeofday | 10 | * Get and set timeofday |
11 | */ | 11 | */ |
12 | extern void do_gettimeofday(struct timeval *tv); | 12 | extern void do_gettimeofday(struct timeval *tv); |
13 | extern int do_settimeofday(const struct timespec *tv); | 13 | extern int do_settimeofday64(const struct timespec64 *ts); |
14 | extern int do_sys_settimeofday(const struct timespec *tv, | 14 | extern int do_sys_settimeofday(const struct timespec *tv, |
15 | const struct timezone *tz); | 15 | const struct timezone *tz); |
16 | 16 | ||
@@ -25,14 +25,22 @@ struct timespec __current_kernel_time(void); | |||
25 | /* | 25 | /* |
26 | * timespec based interfaces | 26 | * timespec based interfaces |
27 | */ | 27 | */ |
28 | struct timespec get_monotonic_coarse(void); | 28 | struct timespec64 get_monotonic_coarse64(void); |
29 | extern void getrawmonotonic(struct timespec *ts); | 29 | extern void getrawmonotonic64(struct timespec64 *ts); |
30 | extern void ktime_get_ts64(struct timespec64 *ts); | 30 | extern void ktime_get_ts64(struct timespec64 *ts); |
31 | 31 | ||
32 | extern int __getnstimeofday64(struct timespec64 *tv); | 32 | extern int __getnstimeofday64(struct timespec64 *tv); |
33 | extern void getnstimeofday64(struct timespec64 *tv); | 33 | extern void getnstimeofday64(struct timespec64 *tv); |
34 | 34 | ||
35 | #if BITS_PER_LONG == 64 | 35 | #if BITS_PER_LONG == 64 |
36 | /** | ||
37 | * Deprecated. Use do_settimeofday64(). | ||
38 | */ | ||
39 | static inline int do_settimeofday(const struct timespec *ts) | ||
40 | { | ||
41 | return do_settimeofday64(ts); | ||
42 | } | ||
43 | |||
36 | static inline int __getnstimeofday(struct timespec *ts) | 44 | static inline int __getnstimeofday(struct timespec *ts) |
37 | { | 45 | { |
38 | return __getnstimeofday64(ts); | 46 | return __getnstimeofday64(ts); |
@@ -53,7 +61,27 @@ static inline void ktime_get_real_ts(struct timespec *ts) | |||
53 | getnstimeofday64(ts); | 61 | getnstimeofday64(ts); |
54 | } | 62 | } |
55 | 63 | ||
64 | static inline void getrawmonotonic(struct timespec *ts) | ||
65 | { | ||
66 | getrawmonotonic64(ts); | ||
67 | } | ||
68 | |||
69 | static inline struct timespec get_monotonic_coarse(void) | ||
70 | { | ||
71 | return get_monotonic_coarse64(); | ||
72 | } | ||
56 | #else | 73 | #else |
74 | /** | ||
75 | * Deprecated. Use do_settimeofday64(). | ||
76 | */ | ||
77 | static inline int do_settimeofday(const struct timespec *ts) | ||
78 | { | ||
79 | struct timespec64 ts64; | ||
80 | |||
81 | ts64 = timespec_to_timespec64(*ts); | ||
82 | return do_settimeofday64(&ts64); | ||
83 | } | ||
84 | |||
57 | static inline int __getnstimeofday(struct timespec *ts) | 85 | static inline int __getnstimeofday(struct timespec *ts) |
58 | { | 86 | { |
59 | struct timespec64 ts64; | 87 | struct timespec64 ts64; |
@@ -86,6 +114,19 @@ static inline void ktime_get_real_ts(struct timespec *ts) | |||
86 | getnstimeofday64(&ts64); | 114 | getnstimeofday64(&ts64); |
87 | *ts = timespec64_to_timespec(ts64); | 115 | *ts = timespec64_to_timespec(ts64); |
88 | } | 116 | } |
117 | |||
118 | static inline void getrawmonotonic(struct timespec *ts) | ||
119 | { | ||
120 | struct timespec64 ts64; | ||
121 | |||
122 | getrawmonotonic64(&ts64); | ||
123 | *ts = timespec64_to_timespec(ts64); | ||
124 | } | ||
125 | |||
126 | static inline struct timespec get_monotonic_coarse(void) | ||
127 | { | ||
128 | return timespec64_to_timespec(get_monotonic_coarse64()); | ||
129 | } | ||
89 | #endif | 130 | #endif |
90 | 131 | ||
91 | extern void getboottime(struct timespec *ts); | 132 | extern void getboottime(struct timespec *ts); |
@@ -182,7 +223,7 @@ static inline void timekeeping_clocktai(struct timespec *ts) | |||
182 | /* | 223 | /* |
183 | * RTC specific | 224 | * RTC specific |
184 | */ | 225 | */ |
185 | extern void timekeeping_inject_sleeptime(struct timespec *delta); | 226 | extern void timekeeping_inject_sleeptime64(struct timespec64 *delta); |
186 | 227 | ||
187 | /* | 228 | /* |
188 | * PPS accessor | 229 | * PPS accessor |
diff --git a/kernel/time/Makefile b/kernel/time/Makefile index 7347426fa68d..f622cf28628a 100644 --- a/kernel/time/Makefile +++ b/kernel/time/Makefile | |||
@@ -13,7 +13,7 @@ obj-$(CONFIG_TICK_ONESHOT) += tick-oneshot.o | |||
13 | obj-$(CONFIG_TICK_ONESHOT) += tick-sched.o | 13 | obj-$(CONFIG_TICK_ONESHOT) += tick-sched.o |
14 | obj-$(CONFIG_TIMER_STATS) += timer_stats.o | 14 | obj-$(CONFIG_TIMER_STATS) += timer_stats.o |
15 | obj-$(CONFIG_DEBUG_FS) += timekeeping_debug.o | 15 | obj-$(CONFIG_DEBUG_FS) += timekeeping_debug.o |
16 | obj-$(CONFIG_TEST_UDELAY) += udelay_test.o | 16 | obj-$(CONFIG_TEST_UDELAY) += test_udelay.o |
17 | 17 | ||
18 | $(obj)/time.o: $(obj)/timeconst.h | 18 | $(obj)/time.o: $(obj)/timeconst.h |
19 | 19 | ||
diff --git a/kernel/time/udelay_test.c b/kernel/time/test_udelay.c index e622ba365a13..e622ba365a13 100644 --- a/kernel/time/udelay_test.c +++ b/kernel/time/test_udelay.c | |||
diff --git a/kernel/time/time.c b/kernel/time/time.c index a9ae20fb0b11..65015ff2f07c 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c | |||
@@ -304,7 +304,9 @@ struct timespec timespec_trunc(struct timespec t, unsigned gran) | |||
304 | } | 304 | } |
305 | EXPORT_SYMBOL(timespec_trunc); | 305 | EXPORT_SYMBOL(timespec_trunc); |
306 | 306 | ||
307 | /* Converts Gregorian date to seconds since 1970-01-01 00:00:00. | 307 | /* |
308 | * mktime64 - Converts date to seconds. | ||
309 | * Converts Gregorian date to seconds since 1970-01-01 00:00:00. | ||
308 | * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 | 310 | * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 |
309 | * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. | 311 | * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. |
310 | * | 312 | * |
@@ -314,15 +316,10 @@ EXPORT_SYMBOL(timespec_trunc); | |||
314 | * -year/100+year/400 terms, and add 10.] | 316 | * -year/100+year/400 terms, and add 10.] |
315 | * | 317 | * |
316 | * This algorithm was first published by Gauss (I think). | 318 | * This algorithm was first published by Gauss (I think). |
317 | * | ||
318 | * WARNING: this function will overflow on 2106-02-07 06:28:16 on | ||
319 | * machines where long is 32-bit! (However, as time_t is signed, we | ||
320 | * will already get problems at other places on 2038-01-19 03:14:08) | ||
321 | */ | 319 | */ |
322 | unsigned long | 320 | time64_t mktime64(const unsigned int year0, const unsigned int mon0, |
323 | mktime(const unsigned int year0, const unsigned int mon0, | 321 | const unsigned int day, const unsigned int hour, |
324 | const unsigned int day, const unsigned int hour, | 322 | const unsigned int min, const unsigned int sec) |
325 | const unsigned int min, const unsigned int sec) | ||
326 | { | 323 | { |
327 | unsigned int mon = mon0, year = year0; | 324 | unsigned int mon = mon0, year = year0; |
328 | 325 | ||
@@ -332,15 +329,14 @@ mktime(const unsigned int year0, const unsigned int mon0, | |||
332 | year -= 1; | 329 | year -= 1; |
333 | } | 330 | } |
334 | 331 | ||
335 | return ((((unsigned long) | 332 | return ((((time64_t) |
336 | (year/4 - year/100 + year/400 + 367*mon/12 + day) + | 333 | (year/4 - year/100 + year/400 + 367*mon/12 + day) + |
337 | year*365 - 719499 | 334 | year*365 - 719499 |
338 | )*24 + hour /* now have hours */ | 335 | )*24 + hour /* now have hours */ |
339 | )*60 + min /* now have minutes */ | 336 | )*60 + min /* now have minutes */ |
340 | )*60 + sec; /* finally seconds */ | 337 | )*60 + sec; /* finally seconds */ |
341 | } | 338 | } |
342 | 339 | EXPORT_SYMBOL(mktime64); | |
343 | EXPORT_SYMBOL(mktime); | ||
344 | 340 | ||
345 | /** | 341 | /** |
346 | * set_normalized_timespec - set timespec sec and nsec parts and normalize | 342 | * set_normalized_timespec - set timespec sec and nsec parts and normalize |
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index ec1791fae965..2dc0646258ae 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -519,9 +519,9 @@ EXPORT_SYMBOL(__getnstimeofday64); | |||
519 | 519 | ||
520 | /** | 520 | /** |
521 | * getnstimeofday64 - Returns the time of day in a timespec64. | 521 | * getnstimeofday64 - Returns the time of day in a timespec64. |
522 | * @ts: pointer to the timespec to be set | 522 | * @ts: pointer to the timespec64 to be set |
523 | * | 523 | * |
524 | * Returns the time of day in a timespec (WARN if suspended). | 524 | * Returns the time of day in a timespec64 (WARN if suspended). |
525 | */ | 525 | */ |
526 | void getnstimeofday64(struct timespec64 *ts) | 526 | void getnstimeofday64(struct timespec64 *ts) |
527 | { | 527 | { |
@@ -623,7 +623,7 @@ EXPORT_SYMBOL_GPL(ktime_get_raw); | |||
623 | * | 623 | * |
624 | * The function calculates the monotonic clock from the realtime | 624 | * The function calculates the monotonic clock from the realtime |
625 | * clock and the wall_to_monotonic offset and stores the result | 625 | * clock and the wall_to_monotonic offset and stores the result |
626 | * in normalized timespec format in the variable pointed to by @ts. | 626 | * in normalized timespec64 format in the variable pointed to by @ts. |
627 | */ | 627 | */ |
628 | void ktime_get_ts64(struct timespec64 *ts) | 628 | void ktime_get_ts64(struct timespec64 *ts) |
629 | { | 629 | { |
@@ -703,18 +703,18 @@ void do_gettimeofday(struct timeval *tv) | |||
703 | EXPORT_SYMBOL(do_gettimeofday); | 703 | EXPORT_SYMBOL(do_gettimeofday); |
704 | 704 | ||
705 | /** | 705 | /** |
706 | * do_settimeofday - Sets the time of day | 706 | * do_settimeofday64 - Sets the time of day. |
707 | * @tv: pointer to the timespec variable containing the new time | 707 | * @ts: pointer to the timespec64 variable containing the new time |
708 | * | 708 | * |
709 | * Sets the time of day to the new time and update NTP and notify hrtimers | 709 | * Sets the time of day to the new time and update NTP and notify hrtimers |
710 | */ | 710 | */ |
711 | int do_settimeofday(const struct timespec *tv) | 711 | int do_settimeofday64(const struct timespec64 *ts) |
712 | { | 712 | { |
713 | struct timekeeper *tk = &tk_core.timekeeper; | 713 | struct timekeeper *tk = &tk_core.timekeeper; |
714 | struct timespec64 ts_delta, xt, tmp; | 714 | struct timespec64 ts_delta, xt; |
715 | unsigned long flags; | 715 | unsigned long flags; |
716 | 716 | ||
717 | if (!timespec_valid_strict(tv)) | 717 | if (!timespec64_valid_strict(ts)) |
718 | return -EINVAL; | 718 | return -EINVAL; |
719 | 719 | ||
720 | raw_spin_lock_irqsave(&timekeeper_lock, flags); | 720 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
@@ -723,13 +723,12 @@ int do_settimeofday(const struct timespec *tv) | |||
723 | timekeeping_forward_now(tk); | 723 | timekeeping_forward_now(tk); |
724 | 724 | ||
725 | xt = tk_xtime(tk); | 725 | xt = tk_xtime(tk); |
726 | ts_delta.tv_sec = tv->tv_sec - xt.tv_sec; | 726 | ts_delta.tv_sec = ts->tv_sec - xt.tv_sec; |
727 | ts_delta.tv_nsec = tv->tv_nsec - xt.tv_nsec; | 727 | ts_delta.tv_nsec = ts->tv_nsec - xt.tv_nsec; |
728 | 728 | ||
729 | tk_set_wall_to_mono(tk, timespec64_sub(tk->wall_to_monotonic, ts_delta)); | 729 | tk_set_wall_to_mono(tk, timespec64_sub(tk->wall_to_monotonic, ts_delta)); |
730 | 730 | ||
731 | tmp = timespec_to_timespec64(*tv); | 731 | tk_set_xtime(tk, ts); |
732 | tk_set_xtime(tk, &tmp); | ||
733 | 732 | ||
734 | timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); | 733 | timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); |
735 | 734 | ||
@@ -741,7 +740,7 @@ int do_settimeofday(const struct timespec *tv) | |||
741 | 740 | ||
742 | return 0; | 741 | return 0; |
743 | } | 742 | } |
744 | EXPORT_SYMBOL(do_settimeofday); | 743 | EXPORT_SYMBOL(do_settimeofday64); |
745 | 744 | ||
746 | /** | 745 | /** |
747 | * timekeeping_inject_offset - Adds or subtracts from the current time. | 746 | * timekeeping_inject_offset - Adds or subtracts from the current time. |
@@ -895,12 +894,12 @@ int timekeeping_notify(struct clocksource *clock) | |||
895 | } | 894 | } |
896 | 895 | ||
897 | /** | 896 | /** |
898 | * getrawmonotonic - Returns the raw monotonic time in a timespec | 897 | * getrawmonotonic64 - Returns the raw monotonic time in a timespec |
899 | * @ts: pointer to the timespec to be set | 898 | * @ts: pointer to the timespec64 to be set |
900 | * | 899 | * |
901 | * Returns the raw monotonic time (completely un-modified by ntp) | 900 | * Returns the raw monotonic time (completely un-modified by ntp) |
902 | */ | 901 | */ |
903 | void getrawmonotonic(struct timespec *ts) | 902 | void getrawmonotonic64(struct timespec64 *ts) |
904 | { | 903 | { |
905 | struct timekeeper *tk = &tk_core.timekeeper; | 904 | struct timekeeper *tk = &tk_core.timekeeper; |
906 | struct timespec64 ts64; | 905 | struct timespec64 ts64; |
@@ -915,9 +914,10 @@ void getrawmonotonic(struct timespec *ts) | |||
915 | } while (read_seqcount_retry(&tk_core.seq, seq)); | 914 | } while (read_seqcount_retry(&tk_core.seq, seq)); |
916 | 915 | ||
917 | timespec64_add_ns(&ts64, nsecs); | 916 | timespec64_add_ns(&ts64, nsecs); |
918 | *ts = timespec64_to_timespec(ts64); | 917 | *ts = ts64; |
919 | } | 918 | } |
920 | EXPORT_SYMBOL(getrawmonotonic); | 919 | EXPORT_SYMBOL(getrawmonotonic64); |
920 | |||
921 | 921 | ||
922 | /** | 922 | /** |
923 | * timekeeping_valid_for_hres - Check if timekeeping is suitable for hres | 923 | * timekeeping_valid_for_hres - Check if timekeeping is suitable for hres |
@@ -1068,8 +1068,8 @@ static void __timekeeping_inject_sleeptime(struct timekeeper *tk, | |||
1068 | } | 1068 | } |
1069 | 1069 | ||
1070 | /** | 1070 | /** |
1071 | * timekeeping_inject_sleeptime - Adds suspend interval to timeekeeping values | 1071 | * timekeeping_inject_sleeptime64 - Adds suspend interval to timeekeeping values |
1072 | * @delta: pointer to a timespec delta value | 1072 | * @delta: pointer to a timespec64 delta value |
1073 | * | 1073 | * |
1074 | * This hook is for architectures that cannot support read_persistent_clock | 1074 | * This hook is for architectures that cannot support read_persistent_clock |
1075 | * because their RTC/persistent clock is only accessible when irqs are enabled. | 1075 | * because their RTC/persistent clock is only accessible when irqs are enabled. |
@@ -1077,10 +1077,9 @@ static void __timekeeping_inject_sleeptime(struct timekeeper *tk, | |||
1077 | * This function should only be called by rtc_resume(), and allows | 1077 | * This function should only be called by rtc_resume(), and allows |
1078 | * a suspend offset to be injected into the timekeeping values. | 1078 | * a suspend offset to be injected into the timekeeping values. |
1079 | */ | 1079 | */ |
1080 | void timekeeping_inject_sleeptime(struct timespec *delta) | 1080 | void timekeeping_inject_sleeptime64(struct timespec64 *delta) |
1081 | { | 1081 | { |
1082 | struct timekeeper *tk = &tk_core.timekeeper; | 1082 | struct timekeeper *tk = &tk_core.timekeeper; |
1083 | struct timespec64 tmp; | ||
1084 | unsigned long flags; | 1083 | unsigned long flags; |
1085 | 1084 | ||
1086 | /* | 1085 | /* |
@@ -1095,8 +1094,7 @@ void timekeeping_inject_sleeptime(struct timespec *delta) | |||
1095 | 1094 | ||
1096 | timekeeping_forward_now(tk); | 1095 | timekeeping_forward_now(tk); |
1097 | 1096 | ||
1098 | tmp = timespec_to_timespec64(*delta); | 1097 | __timekeeping_inject_sleeptime(tk, delta); |
1099 | __timekeeping_inject_sleeptime(tk, &tmp); | ||
1100 | 1098 | ||
1101 | timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); | 1099 | timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); |
1102 | 1100 | ||
@@ -1332,6 +1330,12 @@ static __always_inline void timekeeping_apply_adjustment(struct timekeeper *tk, | |||
1332 | * | 1330 | * |
1333 | * XXX - TODO: Doc ntp_error calculation. | 1331 | * XXX - TODO: Doc ntp_error calculation. |
1334 | */ | 1332 | */ |
1333 | if ((mult_adj > 0) && (tk->tkr.mult + mult_adj < mult_adj)) { | ||
1334 | /* NTP adjustment caused clocksource mult overflow */ | ||
1335 | WARN_ON_ONCE(1); | ||
1336 | return; | ||
1337 | } | ||
1338 | |||
1335 | tk->tkr.mult += mult_adj; | 1339 | tk->tkr.mult += mult_adj; |
1336 | tk->xtime_interval += interval; | 1340 | tk->xtime_interval += interval; |
1337 | tk->tkr.xtime_nsec -= offset; | 1341 | tk->tkr.xtime_nsec -= offset; |
@@ -1397,7 +1401,8 @@ static void timekeeping_adjust(struct timekeeper *tk, s64 offset) | |||
1397 | } | 1401 | } |
1398 | 1402 | ||
1399 | if (unlikely(tk->tkr.clock->maxadj && | 1403 | if (unlikely(tk->tkr.clock->maxadj && |
1400 | (tk->tkr.mult > tk->tkr.clock->mult + tk->tkr.clock->maxadj))) { | 1404 | (abs(tk->tkr.mult - tk->tkr.clock->mult) |
1405 | > tk->tkr.clock->maxadj))) { | ||
1401 | printk_once(KERN_WARNING | 1406 | printk_once(KERN_WARNING |
1402 | "Adjusting %s more than 11%% (%ld vs %ld)\n", | 1407 | "Adjusting %s more than 11%% (%ld vs %ld)\n", |
1403 | tk->tkr.clock->name, (long)tk->tkr.mult, | 1408 | tk->tkr.clock->name, (long)tk->tkr.mult, |
@@ -1646,7 +1651,7 @@ struct timespec current_kernel_time(void) | |||
1646 | } | 1651 | } |
1647 | EXPORT_SYMBOL(current_kernel_time); | 1652 | EXPORT_SYMBOL(current_kernel_time); |
1648 | 1653 | ||
1649 | struct timespec get_monotonic_coarse(void) | 1654 | struct timespec64 get_monotonic_coarse64(void) |
1650 | { | 1655 | { |
1651 | struct timekeeper *tk = &tk_core.timekeeper; | 1656 | struct timekeeper *tk = &tk_core.timekeeper; |
1652 | struct timespec64 now, mono; | 1657 | struct timespec64 now, mono; |
@@ -1662,7 +1667,7 @@ struct timespec get_monotonic_coarse(void) | |||
1662 | set_normalized_timespec64(&now, now.tv_sec + mono.tv_sec, | 1667 | set_normalized_timespec64(&now, now.tv_sec + mono.tv_sec, |
1663 | now.tv_nsec + mono.tv_nsec); | 1668 | now.tv_nsec + mono.tv_nsec); |
1664 | 1669 | ||
1665 | return timespec64_to_timespec(now); | 1670 | return now; |
1666 | } | 1671 | } |
1667 | 1672 | ||
1668 | /* | 1673 | /* |