diff options
Diffstat (limited to 'kernel/time/clockevents.c')
-rw-r--r-- | kernel/time/clockevents.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c index d13be216a790..20a8920029ee 100644 --- a/kernel/time/clockevents.c +++ b/kernel/time/clockevents.c | |||
@@ -18,6 +18,9 @@ | |||
18 | #include <linux/notifier.h> | 18 | #include <linux/notifier.h> |
19 | #include <linux/smp.h> | 19 | #include <linux/smp.h> |
20 | #include <linux/sysdev.h> | 20 | #include <linux/sysdev.h> |
21 | #include <linux/tick.h> | ||
22 | |||
23 | #include "tick-internal.h" | ||
21 | 24 | ||
22 | /* The registered clock event devices */ | 25 | /* The registered clock event devices */ |
23 | static LIST_HEAD(clockevent_devices); | 26 | static LIST_HEAD(clockevent_devices); |
@@ -36,10 +39,9 @@ static DEFINE_SPINLOCK(clockevents_lock); | |||
36 | * | 39 | * |
37 | * Math helper, returns latch value converted to nanoseconds (bound checked) | 40 | * Math helper, returns latch value converted to nanoseconds (bound checked) |
38 | */ | 41 | */ |
39 | unsigned long clockevent_delta2ns(unsigned long latch, | 42 | u64 clockevent_delta2ns(unsigned long latch, struct clock_event_device *evt) |
40 | struct clock_event_device *evt) | ||
41 | { | 43 | { |
42 | u64 clc = ((u64) latch << evt->shift); | 44 | u64 clc = (u64) latch << evt->shift; |
43 | 45 | ||
44 | if (unlikely(!evt->mult)) { | 46 | if (unlikely(!evt->mult)) { |
45 | evt->mult = 1; | 47 | evt->mult = 1; |
@@ -49,11 +51,12 @@ unsigned long clockevent_delta2ns(unsigned long latch, | |||
49 | do_div(clc, evt->mult); | 51 | do_div(clc, evt->mult); |
50 | if (clc < 1000) | 52 | if (clc < 1000) |
51 | clc = 1000; | 53 | clc = 1000; |
52 | if (clc > LONG_MAX) | 54 | if (clc > KTIME_MAX) |
53 | clc = LONG_MAX; | 55 | clc = KTIME_MAX; |
54 | 56 | ||
55 | return (unsigned long) clc; | 57 | return clc; |
56 | } | 58 | } |
59 | EXPORT_SYMBOL_GPL(clockevent_delta2ns); | ||
57 | 60 | ||
58 | /** | 61 | /** |
59 | * clockevents_set_mode - set the operating mode of a clock event device | 62 | * clockevents_set_mode - set the operating mode of a clock event device |
@@ -135,11 +138,12 @@ int clockevents_program_event(struct clock_event_device *dev, ktime_t expires, | |||
135 | */ | 138 | */ |
136 | int clockevents_register_notifier(struct notifier_block *nb) | 139 | int clockevents_register_notifier(struct notifier_block *nb) |
137 | { | 140 | { |
141 | unsigned long flags; | ||
138 | int ret; | 142 | int ret; |
139 | 143 | ||
140 | spin_lock(&clockevents_lock); | 144 | spin_lock_irqsave(&clockevents_lock, flags); |
141 | ret = raw_notifier_chain_register(&clockevents_chain, nb); | 145 | ret = raw_notifier_chain_register(&clockevents_chain, nb); |
142 | spin_unlock(&clockevents_lock); | 146 | spin_unlock_irqrestore(&clockevents_lock, flags); |
143 | 147 | ||
144 | return ret; | 148 | return ret; |
145 | } | 149 | } |
@@ -176,17 +180,20 @@ static void clockevents_notify_released(void) | |||
176 | */ | 180 | */ |
177 | void clockevents_register_device(struct clock_event_device *dev) | 181 | void clockevents_register_device(struct clock_event_device *dev) |
178 | { | 182 | { |
183 | unsigned long flags; | ||
184 | |||
179 | BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED); | 185 | BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED); |
180 | BUG_ON(!dev->cpumask); | 186 | BUG_ON(!dev->cpumask); |
181 | 187 | ||
182 | spin_lock(&clockevents_lock); | 188 | spin_lock_irqsave(&clockevents_lock, flags); |
183 | 189 | ||
184 | list_add(&dev->list, &clockevent_devices); | 190 | list_add(&dev->list, &clockevent_devices); |
185 | clockevents_do_notify(CLOCK_EVT_NOTIFY_ADD, dev); | 191 | clockevents_do_notify(CLOCK_EVT_NOTIFY_ADD, dev); |
186 | clockevents_notify_released(); | 192 | clockevents_notify_released(); |
187 | 193 | ||
188 | spin_unlock(&clockevents_lock); | 194 | spin_unlock_irqrestore(&clockevents_lock, flags); |
189 | } | 195 | } |
196 | EXPORT_SYMBOL_GPL(clockevents_register_device); | ||
190 | 197 | ||
191 | /* | 198 | /* |
192 | * Noop handler when we shut down an event device | 199 | * Noop handler when we shut down an event device |
@@ -232,8 +239,9 @@ void clockevents_exchange_device(struct clock_event_device *old, | |||
232 | void clockevents_notify(unsigned long reason, void *arg) | 239 | void clockevents_notify(unsigned long reason, void *arg) |
233 | { | 240 | { |
234 | struct list_head *node, *tmp; | 241 | struct list_head *node, *tmp; |
242 | unsigned long flags; | ||
235 | 243 | ||
236 | spin_lock(&clockevents_lock); | 244 | spin_lock_irqsave(&clockevents_lock, flags); |
237 | clockevents_do_notify(reason, arg); | 245 | clockevents_do_notify(reason, arg); |
238 | 246 | ||
239 | switch (reason) { | 247 | switch (reason) { |
@@ -248,7 +256,7 @@ void clockevents_notify(unsigned long reason, void *arg) | |||
248 | default: | 256 | default: |
249 | break; | 257 | break; |
250 | } | 258 | } |
251 | spin_unlock(&clockevents_lock); | 259 | spin_unlock_irqrestore(&clockevents_lock, flags); |
252 | } | 260 | } |
253 | EXPORT_SYMBOL_GPL(clockevents_notify); | 261 | EXPORT_SYMBOL_GPL(clockevents_notify); |
254 | #endif | 262 | #endif |