blob: 0a23f4f299343ad1fffd89f8d2c6fad4525bb38b [file] [log] [blame]
Thomas Gleixnerd316c572007-02-16 01:28:00 -08001/*
2 * linux/kernel/time/clockevents.c
3 *
4 * This file contains functions which manage clock event devices.
5 *
6 * Copyright(C) 2005-2006, Thomas Gleixner <tglx@linutronix.de>
7 * Copyright(C) 2005-2007, Red Hat, Inc., Ingo Molnar
8 * Copyright(C) 2006-2007, Timesys Corp., Thomas Gleixner
9 *
10 * This code is licenced under the GPL version 2. For details see
11 * kernel-base/COPYING.
12 */
13
14#include <linux/clockchips.h>
15#include <linux/hrtimer.h>
16#include <linux/init.h>
17#include <linux/module.h>
Thomas Gleixnerd316c572007-02-16 01:28:00 -080018#include <linux/smp.h>
Thomas Gleixner501f8672013-04-25 20:31:49 +000019#include <linux/device.h>
Thomas Gleixnerd316c572007-02-16 01:28:00 -080020
H Hartley Sweeten8e1a9282009-10-16 18:19:01 -040021#include "tick-internal.h"
22
Thomas Gleixnerd316c572007-02-16 01:28:00 -080023/* The registered clock event devices */
24static LIST_HEAD(clockevent_devices);
25static LIST_HEAD(clockevents_released);
Thomas Gleixnerd316c572007-02-16 01:28:00 -080026/* Protection for the above */
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +010027static DEFINE_RAW_SPINLOCK(clockevents_lock);
Thomas Gleixnerd316c572007-02-16 01:28:00 -080028
29/**
30 * clockevents_delta2ns - Convert a latch value (device ticks) to nanoseconds
31 * @latch: value to convert
32 * @evt: pointer to clock event device descriptor
33 *
34 * Math helper, returns latch value converted to nanoseconds (bound checked)
35 */
Jon Hunter97813f22009-08-18 12:45:11 -050036u64 clockevent_delta2ns(unsigned long latch, struct clock_event_device *evt)
Thomas Gleixnerd316c572007-02-16 01:28:00 -080037{
Jon Hunter97813f22009-08-18 12:45:11 -050038 u64 clc = (u64) latch << evt->shift;
Thomas Gleixnerd316c572007-02-16 01:28:00 -080039
Ingo Molnar45fe4fe2008-01-30 13:30:03 +010040 if (unlikely(!evt->mult)) {
41 evt->mult = 1;
42 WARN_ON(1);
43 }
44
Thomas Gleixnerd316c572007-02-16 01:28:00 -080045 do_div(clc, evt->mult);
46 if (clc < 1000)
47 clc = 1000;
Jon Hunter97813f22009-08-18 12:45:11 -050048 if (clc > KTIME_MAX)
49 clc = KTIME_MAX;
Thomas Gleixnerd316c572007-02-16 01:28:00 -080050
Jon Hunter97813f22009-08-18 12:45:11 -050051 return clc;
Thomas Gleixnerd316c572007-02-16 01:28:00 -080052}
Magnus Dammc81fc2c2009-05-01 14:52:47 +090053EXPORT_SYMBOL_GPL(clockevent_delta2ns);
Thomas Gleixnerd316c572007-02-16 01:28:00 -080054
55/**
56 * clockevents_set_mode - set the operating mode of a clock event device
57 * @dev: device to modify
58 * @mode: new mode
59 *
60 * Must be called with interrupts disabled !
61 */
62void clockevents_set_mode(struct clock_event_device *dev,
63 enum clock_event_mode mode)
64{
65 if (dev->mode != mode) {
66 dev->set_mode(mode, dev);
67 dev->mode = mode;
Magnus Damm2d682592009-01-16 17:14:38 +090068
69 /*
70 * A nsec2cyc multiplicator of 0 is invalid and we'd crash
71 * on it, so fix it up and emit a warning:
72 */
73 if (mode == CLOCK_EVT_MODE_ONESHOT) {
74 if (unlikely(!dev->mult)) {
75 dev->mult = 1;
76 WARN_ON(1);
77 }
78 }
Thomas Gleixnerd316c572007-02-16 01:28:00 -080079 }
80}
81
82/**
Thomas Gleixner2344abb2008-09-16 11:32:50 -070083 * clockevents_shutdown - shutdown the device and clear next_event
84 * @dev: device to shutdown
85 */
86void clockevents_shutdown(struct clock_event_device *dev)
87{
88 clockevents_set_mode(dev, CLOCK_EVT_MODE_SHUTDOWN);
89 dev->next_event.tv64 = KTIME_MAX;
90}
91
Martin Schwidefskyd1748302011-08-23 15:29:42 +020092#ifdef CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST
93
94/* Limit min_delta to a jiffie */
95#define MIN_DELTA_LIMIT (NSEC_PER_SEC / HZ)
96
97/**
98 * clockevents_increase_min_delta - raise minimum delta of a clock event device
99 * @dev: device to increase the minimum delta
100 *
101 * Returns 0 on success, -ETIME when the minimum delta reached the limit.
102 */
103static int clockevents_increase_min_delta(struct clock_event_device *dev)
104{
105 /* Nothing to do if we already reached the limit */
106 if (dev->min_delta_ns >= MIN_DELTA_LIMIT) {
107 printk(KERN_WARNING "CE: Reprogramming failure. Giving up\n");
108 dev->next_event.tv64 = KTIME_MAX;
109 return -ETIME;
110 }
111
112 if (dev->min_delta_ns < 5000)
113 dev->min_delta_ns = 5000;
114 else
115 dev->min_delta_ns += dev->min_delta_ns >> 1;
116
117 if (dev->min_delta_ns > MIN_DELTA_LIMIT)
118 dev->min_delta_ns = MIN_DELTA_LIMIT;
119
120 printk(KERN_WARNING "CE: %s increased min_delta_ns to %llu nsec\n",
121 dev->name ? dev->name : "?",
122 (unsigned long long) dev->min_delta_ns);
123 return 0;
124}
125
126/**
127 * clockevents_program_min_delta - Set clock event device to the minimum delay.
128 * @dev: device to program
129 *
130 * Returns 0 on success, -ETIME when the retry loop failed.
131 */
132static int clockevents_program_min_delta(struct clock_event_device *dev)
133{
134 unsigned long long clc;
135 int64_t delta;
136 int i;
137
138 for (i = 0;;) {
139 delta = dev->min_delta_ns;
140 dev->next_event = ktime_add_ns(ktime_get(), delta);
141
142 if (dev->mode == CLOCK_EVT_MODE_SHUTDOWN)
143 return 0;
144
145 dev->retries++;
146 clc = ((unsigned long long) delta * dev->mult) >> dev->shift;
147 if (dev->set_next_event((unsigned long) clc, dev) == 0)
148 return 0;
149
150 if (++i > 2) {
151 /*
152 * We tried 3 times to program the device with the
153 * given min_delta_ns. Try to increase the minimum
154 * delta, if that fails as well get out of here.
155 */
156 if (clockevents_increase_min_delta(dev))
157 return -ETIME;
158 i = 0;
159 }
160 }
161}
162
163#else /* CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST */
164
165/**
166 * clockevents_program_min_delta - Set clock event device to the minimum delay.
167 * @dev: device to program
168 *
169 * Returns 0 on success, -ETIME when the retry loop failed.
170 */
171static int clockevents_program_min_delta(struct clock_event_device *dev)
172{
173 unsigned long long clc;
174 int64_t delta;
175
176 delta = dev->min_delta_ns;
177 dev->next_event = ktime_add_ns(ktime_get(), delta);
178
179 if (dev->mode == CLOCK_EVT_MODE_SHUTDOWN)
180 return 0;
181
182 dev->retries++;
183 clc = ((unsigned long long) delta * dev->mult) >> dev->shift;
184 return dev->set_next_event((unsigned long) clc, dev);
185}
186
187#endif /* CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST */
188
Thomas Gleixner2344abb2008-09-16 11:32:50 -0700189/**
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800190 * clockevents_program_event - Reprogram the clock event device.
Martin Schwidefskyd1748302011-08-23 15:29:42 +0200191 * @dev: device to program
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800192 * @expires: absolute expiry time (monotonic clock)
Martin Schwidefskyd1748302011-08-23 15:29:42 +0200193 * @force: program minimum delay if expires can not be set
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800194 *
195 * Returns 0 on success, -ETIME when the event is in the past.
196 */
197int clockevents_program_event(struct clock_event_device *dev, ktime_t expires,
Martin Schwidefskyd1748302011-08-23 15:29:42 +0200198 bool force)
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800199{
200 unsigned long long clc;
201 int64_t delta;
Martin Schwidefskyd1748302011-08-23 15:29:42 +0200202 int rc;
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800203
Thomas Gleixner167b1de2007-12-07 19:16:17 +0100204 if (unlikely(expires.tv64 < 0)) {
205 WARN_ON_ONCE(1);
206 return -ETIME;
207 }
208
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800209 dev->next_event = expires;
210
211 if (dev->mode == CLOCK_EVT_MODE_SHUTDOWN)
212 return 0;
213
Martin Schwidefsky65516f82011-08-23 15:29:43 +0200214 /* Shortcut for clockevent devices that can deal with ktime. */
215 if (dev->features & CLOCK_EVT_FEAT_KTIME)
216 return dev->set_next_ktime(expires, dev);
217
Martin Schwidefskyd1748302011-08-23 15:29:42 +0200218 delta = ktime_to_ns(ktime_sub(expires, ktime_get()));
219 if (delta <= 0)
220 return force ? clockevents_program_min_delta(dev) : -ETIME;
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800221
Martin Schwidefskyd1748302011-08-23 15:29:42 +0200222 delta = min(delta, (int64_t) dev->max_delta_ns);
223 delta = max(delta, (int64_t) dev->min_delta_ns);
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800224
Martin Schwidefskyd1748302011-08-23 15:29:42 +0200225 clc = ((unsigned long long) delta * dev->mult) >> dev->shift;
226 rc = dev->set_next_event((unsigned long) clc, dev);
227
228 return (rc && force) ? clockevents_program_min_delta(dev) : rc;
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800229}
230
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800231/*
Li Zefan3eb05672008-02-08 04:19:25 -0800232 * Called after a notify add to make devices available which were
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800233 * released from the notifier call.
234 */
235static void clockevents_notify_released(void)
236{
237 struct clock_event_device *dev;
238
239 while (!list_empty(&clockevents_released)) {
240 dev = list_entry(clockevents_released.next,
241 struct clock_event_device, list);
242 list_del(&dev->list);
243 list_add(&dev->list, &clockevent_devices);
Thomas Gleixner7172a282013-04-25 20:31:47 +0000244 tick_check_new_device(dev);
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800245 }
246}
247
248/**
249 * clockevents_register_device - register a clock event device
250 * @dev: device to register
251 */
252void clockevents_register_device(struct clock_event_device *dev)
253{
Suresh Siddhaf833bab2009-08-17 14:34:59 -0700254 unsigned long flags;
255
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800256 BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED);
Thomas Gleixner1b054b62011-06-03 11:13:33 +0200257 if (!dev->cpumask) {
258 WARN_ON(num_possible_cpus() > 1);
259 dev->cpumask = cpumask_of(smp_processor_id());
260 }
Rusty Russell320ab2b2008-12-13 21:20:26 +1030261
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100262 raw_spin_lock_irqsave(&clockevents_lock, flags);
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800263
264 list_add(&dev->list, &clockevent_devices);
Thomas Gleixner7172a282013-04-25 20:31:47 +0000265 tick_check_new_device(dev);
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800266 clockevents_notify_released();
267
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100268 raw_spin_unlock_irqrestore(&clockevents_lock, flags);
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800269}
Magnus Dammc81fc2c2009-05-01 14:52:47 +0900270EXPORT_SYMBOL_GPL(clockevents_register_device);
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800271
Magnus Damme5400322012-05-09 23:39:34 +0900272void clockevents_config(struct clock_event_device *dev, u32 freq)
Thomas Gleixner57f0fcb2011-05-18 21:33:41 +0000273{
Thomas Gleixnerc0e299b2011-05-20 10:50:52 +0200274 u64 sec;
Thomas Gleixner57f0fcb2011-05-18 21:33:41 +0000275
276 if (!(dev->features & CLOCK_EVT_FEAT_ONESHOT))
277 return;
278
279 /*
280 * Calculate the maximum number of seconds we can sleep. Limit
281 * to 10 minutes for hardware which can program more than
282 * 32bit ticks so we still get reasonable conversion values.
283 */
284 sec = dev->max_delta_ticks;
285 do_div(sec, freq);
286 if (!sec)
287 sec = 1;
288 else if (sec > 600 && dev->max_delta_ticks > UINT_MAX)
289 sec = 600;
290
291 clockevents_calc_mult_shift(dev, freq, sec);
292 dev->min_delta_ns = clockevent_delta2ns(dev->min_delta_ticks, dev);
293 dev->max_delta_ns = clockevent_delta2ns(dev->max_delta_ticks, dev);
294}
295
296/**
297 * clockevents_config_and_register - Configure and register a clock event device
298 * @dev: device to register
299 * @freq: The clock frequency
300 * @min_delta: The minimum clock ticks to program in oneshot mode
301 * @max_delta: The maximum clock ticks to program in oneshot mode
302 *
303 * min/max_delta can be 0 for devices which do not support oneshot mode.
304 */
305void clockevents_config_and_register(struct clock_event_device *dev,
306 u32 freq, unsigned long min_delta,
307 unsigned long max_delta)
308{
309 dev->min_delta_ticks = min_delta;
310 dev->max_delta_ticks = max_delta;
311 clockevents_config(dev, freq);
312 clockevents_register_device(dev);
313}
Shawn Guoc35ef952013-01-12 11:50:04 +0000314EXPORT_SYMBOL_GPL(clockevents_config_and_register);
Thomas Gleixner57f0fcb2011-05-18 21:33:41 +0000315
Thomas Gleixner80b816b2011-05-18 21:33:42 +0000316/**
317 * clockevents_update_freq - Update frequency and reprogram a clock event device.
318 * @dev: device to modify
319 * @freq: new device frequency
320 *
321 * Reconfigure and reprogram a clock event device in oneshot
322 * mode. Must be called on the cpu for which the device delivers per
323 * cpu timer events with interrupts disabled! Returns 0 on success,
324 * -ETIME when the event is in the past.
325 */
326int clockevents_update_freq(struct clock_event_device *dev, u32 freq)
327{
328 clockevents_config(dev, freq);
329
330 if (dev->mode != CLOCK_EVT_MODE_ONESHOT)
331 return 0;
332
Martin Schwidefskyd1748302011-08-23 15:29:42 +0200333 return clockevents_program_event(dev, dev->next_event, false);
Thomas Gleixner80b816b2011-05-18 21:33:42 +0000334}
335
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800336/*
337 * Noop handler when we shut down an event device
338 */
Venkatesh Pallipadi7c1e7682008-09-03 21:36:50 +0000339void clockevents_handle_noop(struct clock_event_device *dev)
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800340{
341}
342
343/**
344 * clockevents_exchange_device - release and request clock devices
345 * @old: device to release (can be NULL)
346 * @new: device to request (can be NULL)
347 *
348 * Called from the notifier chain. clockevents_lock is held already
349 */
350void clockevents_exchange_device(struct clock_event_device *old,
351 struct clock_event_device *new)
352{
353 unsigned long flags;
354
355 local_irq_save(flags);
356 /*
357 * Caller releases a clock event device. We queue it into the
358 * released list and do a notify add later.
359 */
360 if (old) {
Thomas Gleixnerccf33d62013-04-25 20:31:49 +0000361 module_put(old->owner);
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800362 clockevents_set_mode(old, CLOCK_EVT_MODE_UNUSED);
363 list_del(&old->list);
364 list_add(&old->list, &clockevents_released);
365 }
366
367 if (new) {
368 BUG_ON(new->mode != CLOCK_EVT_MODE_UNUSED);
Thomas Gleixner2344abb2008-09-16 11:32:50 -0700369 clockevents_shutdown(new);
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800370 }
371 local_irq_restore(flags);
372}
373
Rafael J. Wysockiadc78e62012-08-06 01:40:41 +0200374/**
375 * clockevents_suspend - suspend clock devices
376 */
377void clockevents_suspend(void)
378{
379 struct clock_event_device *dev;
380
381 list_for_each_entry_reverse(dev, &clockevent_devices, list)
382 if (dev->suspend)
383 dev->suspend(dev);
384}
385
386/**
387 * clockevents_resume - resume clock devices
388 */
389void clockevents_resume(void)
390{
391 struct clock_event_device *dev;
392
393 list_for_each_entry(dev, &clockevent_devices, list)
394 if (dev->resume)
395 dev->resume(dev);
396}
397
Thomas Gleixnerde68d9b2007-10-12 23:04:05 +0200398#ifdef CONFIG_GENERIC_CLOCKEVENTS
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800399/**
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800400 * clockevents_notify - notification about relevant events
401 */
402void clockevents_notify(unsigned long reason, void *arg)
403{
Thomas Gleixnerbb6eddf2009-12-10 15:35:10 +0100404 struct clock_event_device *dev, *tmp;
Suresh Siddhaf833bab2009-08-17 14:34:59 -0700405 unsigned long flags;
Thomas Gleixnerbb6eddf2009-12-10 15:35:10 +0100406 int cpu;
Li Zefan0b858e62008-02-08 04:19:24 -0800407
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100408 raw_spin_lock_irqsave(&clockevents_lock, flags);
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800409
410 switch (reason) {
Thomas Gleixner8c53daf2013-04-25 20:31:48 +0000411 case CLOCK_EVT_NOTIFY_BROADCAST_ON:
412 case CLOCK_EVT_NOTIFY_BROADCAST_OFF:
413 case CLOCK_EVT_NOTIFY_BROADCAST_FORCE:
414 tick_broadcast_on_off(reason, arg);
415 break;
416
417 case CLOCK_EVT_NOTIFY_BROADCAST_ENTER:
418 case CLOCK_EVT_NOTIFY_BROADCAST_EXIT:
419 tick_broadcast_oneshot_control(reason);
420 break;
421
422 case CLOCK_EVT_NOTIFY_CPU_DYING:
423 tick_handover_do_timer(arg);
424 break;
425
426 case CLOCK_EVT_NOTIFY_SUSPEND:
427 tick_suspend();
428 tick_suspend_broadcast();
429 break;
430
431 case CLOCK_EVT_NOTIFY_RESUME:
432 tick_resume();
433 break;
434
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800435 case CLOCK_EVT_NOTIFY_CPU_DEAD:
Thomas Gleixner8c53daf2013-04-25 20:31:48 +0000436 tick_shutdown_broadcast_oneshot(arg);
437 tick_shutdown_broadcast(arg);
438 tick_shutdown(arg);
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800439 /*
440 * Unregister the clock event devices which were
441 * released from the users in the notify chain.
442 */
Thomas Gleixnerbb6eddf2009-12-10 15:35:10 +0100443 list_for_each_entry_safe(dev, tmp, &clockevents_released, list)
444 list_del(&dev->list);
445 /*
446 * Now check whether the CPU has left unused per cpu devices
447 */
448 cpu = *((int *)arg);
449 list_for_each_entry_safe(dev, tmp, &clockevent_devices, list) {
450 if (cpumask_test_cpu(cpu, dev->cpumask) &&
Xiaotian Fengea9d8e32010-01-07 11:22:44 +0800451 cpumask_weight(dev->cpumask) == 1 &&
452 !tick_is_broadcast_device(dev)) {
Thomas Gleixnerbb6eddf2009-12-10 15:35:10 +0100453 BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED);
454 list_del(&dev->list);
455 }
456 }
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800457 break;
458 default:
459 break;
460 }
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100461 raw_spin_unlock_irqrestore(&clockevents_lock, flags);
Thomas Gleixnerd316c572007-02-16 01:28:00 -0800462}
463EXPORT_SYMBOL_GPL(clockevents_notify);
Thomas Gleixner501f8672013-04-25 20:31:49 +0000464
465#ifdef CONFIG_SYSFS
466struct bus_type clockevents_subsys = {
467 .name = "clockevents",
468 .dev_name = "clockevent",
469};
470
471static DEFINE_PER_CPU(struct device, tick_percpu_dev);
472static struct tick_device *tick_get_tick_dev(struct device *dev);
473
474static ssize_t sysfs_show_current_tick_dev(struct device *dev,
475 struct device_attribute *attr,
476 char *buf)
477{
478 struct tick_device *td;
479 ssize_t count = 0;
480
481 raw_spin_lock_irq(&clockevents_lock);
482 td = tick_get_tick_dev(dev);
483 if (td && td->evtdev)
484 count = snprintf(buf, PAGE_SIZE, "%s\n", td->evtdev->name);
485 raw_spin_unlock_irq(&clockevents_lock);
486 return count;
487}
488static DEVICE_ATTR(current_device, 0444, sysfs_show_current_tick_dev, NULL);
489
490#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
491static struct device tick_bc_dev = {
492 .init_name = "broadcast",
493 .id = 0,
494 .bus = &clockevents_subsys,
495};
496
497static struct tick_device *tick_get_tick_dev(struct device *dev)
498{
499 return dev == &tick_bc_dev ? tick_get_broadcast_device() :
500 &per_cpu(tick_cpu_device, dev->id);
501}
502
503static __init int tick_broadcast_init_sysfs(void)
504{
505 int err = device_register(&tick_bc_dev);
506
507 if (!err)
508 err = device_create_file(&tick_bc_dev, &dev_attr_current_device);
509 return err;
510}
511#else
512static struct tick_device *tick_get_tick_dev(struct device *dev)
513{
514 return &per_cpu(tick_cpu_device, dev->id);
515}
516static inline int tick_broadcast_init_sysfs(void) { return 0; }
Thomas Gleixnerde68d9b2007-10-12 23:04:05 +0200517#endif
Thomas Gleixner501f8672013-04-25 20:31:49 +0000518
519static int __init tick_init_sysfs(void)
520{
521 int cpu;
522
523 for_each_possible_cpu(cpu) {
524 struct device *dev = &per_cpu(tick_percpu_dev, cpu);
525 int err;
526
527 dev->id = cpu;
528 dev->bus = &clockevents_subsys;
529 err = device_register(dev);
530 if (!err)
531 err = device_create_file(dev, &dev_attr_current_device);
532 if (err)
533 return err;
534 }
535 return tick_broadcast_init_sysfs();
536}
537
538static int __init clockevents_init_sysfs(void)
539{
540 int err = subsys_system_register(&clockevents_subsys, NULL);
541
542 if (!err)
543 err = tick_init_sysfs();
544 return err;
545}
546device_initcall(clockevents_init_sysfs);
547#endif /* SYSFS */
548
549#endif /* GENERIC_CLOCK_EVENTS */