clockevents.c (d7eb231c71420bc34ac3d35403115600f920cfc2) clockevents.c (051ebd101b05c09d9b5b673e19fb0586e9bfec56)
1/*
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

--- 123 unchanged lines hidden (view full) ---

132 /* Core internal bug */
133 if (!(dev->features & CLOCK_EVT_FEAT_ONESHOT))
134 return -ENOSYS;
135 return dev->set_state_oneshot(dev);
136
137 case CLOCK_EVT_STATE_ONESHOT_STOPPED:
138 /* Core internal bug */
139 if (WARN_ONCE(!clockevent_state_oneshot(dev),
1/*
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

--- 123 unchanged lines hidden (view full) ---

132 /* Core internal bug */
133 if (!(dev->features & CLOCK_EVT_FEAT_ONESHOT))
134 return -ENOSYS;
135 return dev->set_state_oneshot(dev);
136
137 case CLOCK_EVT_STATE_ONESHOT_STOPPED:
138 /* Core internal bug */
139 if (WARN_ONCE(!clockevent_state_oneshot(dev),
140 "Current state: %d\n", dev->state))
140 "Current state: %d\n",
141 clockevent_get_state(dev)))
141 return -EINVAL;
142
143 if (dev->set_state_oneshot_stopped)
144 return dev->set_state_oneshot_stopped(dev);
145 else
146 return -ENOSYS;
147
148 default:

--- 6 unchanged lines hidden (view full) ---

155 * @dev: device to modify
156 * @state: new state
157 *
158 * Must be called with interrupts disabled !
159 */
160void clockevents_switch_state(struct clock_event_device *dev,
161 enum clock_event_state state)
162{
142 return -EINVAL;
143
144 if (dev->set_state_oneshot_stopped)
145 return dev->set_state_oneshot_stopped(dev);
146 else
147 return -ENOSYS;
148
149 default:

--- 6 unchanged lines hidden (view full) ---

156 * @dev: device to modify
157 * @state: new state
158 *
159 * Must be called with interrupts disabled !
160 */
161void clockevents_switch_state(struct clock_event_device *dev,
162 enum clock_event_state state)
163{
163 if (dev->state != state) {
164 if (clockevent_get_state(dev) != state) {
164 if (__clockevents_switch_state(dev, state))
165 return;
166
165 if (__clockevents_switch_state(dev, state))
166 return;
167
167 dev->state = state;
168 clockevent_set_state(dev, state);
168
169 /*
170 * A nsec2cyc multiplicator of 0 is invalid and we'd crash
171 * on it, so fix it up and emit a warning:
172 */
173 if (clockevent_state_oneshot(dev)) {
174 if (unlikely(!dev->mult)) {
175 dev->mult = 1;

--- 152 unchanged lines hidden (view full) ---

328
329 dev->next_event = expires;
330
331 if (clockevent_state_shutdown(dev))
332 return 0;
333
334 /* We must be in ONESHOT state here */
335 WARN_ONCE(!clockevent_state_oneshot(dev), "Current state: %d\n",
169
170 /*
171 * A nsec2cyc multiplicator of 0 is invalid and we'd crash
172 * on it, so fix it up and emit a warning:
173 */
174 if (clockevent_state_oneshot(dev)) {
175 if (unlikely(!dev->mult)) {
176 dev->mult = 1;

--- 152 unchanged lines hidden (view full) ---

329
330 dev->next_event = expires;
331
332 if (clockevent_state_shutdown(dev))
333 return 0;
334
335 /* We must be in ONESHOT state here */
336 WARN_ONCE(!clockevent_state_oneshot(dev), "Current state: %d\n",
336 dev->state);
337 clockevent_get_state(dev));
337
338 /* Shortcut for clockevent devices that can deal with ktime. */
339 if (dev->features & CLOCK_EVT_FEAT_KTIME)
340 return dev->set_next_ktime(expires, dev);
341
342 delta = ktime_to_ns(ktime_sub(expires, ktime_get()));
343 if (delta <= 0)
344 return force ? clockevents_program_min_delta(dev) : -ETIME;

--- 146 unchanged lines hidden (view full) ---

491 */
492void clockevents_register_device(struct clock_event_device *dev)
493{
494 unsigned long flags;
495
496 BUG_ON(clockevents_sanity_check(dev));
497
498 /* Initialize state to DETACHED */
338
339 /* Shortcut for clockevent devices that can deal with ktime. */
340 if (dev->features & CLOCK_EVT_FEAT_KTIME)
341 return dev->set_next_ktime(expires, dev);
342
343 delta = ktime_to_ns(ktime_sub(expires, ktime_get()));
344 if (delta <= 0)
345 return force ? clockevents_program_min_delta(dev) : -ETIME;

--- 146 unchanged lines hidden (view full) ---

492 */
493void clockevents_register_device(struct clock_event_device *dev)
494{
495 unsigned long flags;
496
497 BUG_ON(clockevents_sanity_check(dev));
498
499 /* Initialize state to DETACHED */
499 dev->state = CLOCK_EVT_STATE_DETACHED;
500 clockevent_set_state(dev, CLOCK_EVT_STATE_DETACHED);
500
501 if (!dev->cpumask) {
502 WARN_ON(num_possible_cpus() > 1);
503 dev->cpumask = cpumask_of(smp_processor_id());
504 }
505
506 raw_spin_lock_irqsave(&clockevents_lock, flags);
507

--- 301 unchanged lines hidden ---
501
502 if (!dev->cpumask) {
503 WARN_ON(num_possible_cpus() > 1);
504 dev->cpumask = cpumask_of(smp_processor_id());
505 }
506
507 raw_spin_lock_irqsave(&clockevents_lock, flags);
508

--- 301 unchanged lines hidden ---