Commit 472c4a94 authored by Viresh Kumar's avatar Viresh Kumar Committed by Thomas Gleixner

clockevents: Use helpers to check the state of a clockevent device

Use accessor functions to check the state of clockevent devices in
core code.
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Cc: linaro-kernel@lists.linaro.org
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/fa2b9869fd17f210eaa156ec2b594efd0230b6c7.1432192527.git.viresh.kumar@linaro.orgSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 3434d23b
...@@ -136,7 +136,7 @@ static int __clockevents_set_state(struct clock_event_device *dev, ...@@ -136,7 +136,7 @@ static int __clockevents_set_state(struct clock_event_device *dev,
case CLOCK_EVT_STATE_ONESHOT_STOPPED: case CLOCK_EVT_STATE_ONESHOT_STOPPED:
/* Core internal bug */ /* Core internal bug */
if (WARN_ONCE(dev->state != CLOCK_EVT_STATE_ONESHOT, if (WARN_ONCE(!clockevent_state_oneshot(dev),
"Current state: %d\n", dev->state)) "Current state: %d\n", dev->state))
return -EINVAL; return -EINVAL;
...@@ -170,7 +170,7 @@ void clockevents_set_state(struct clock_event_device *dev, ...@@ -170,7 +170,7 @@ void clockevents_set_state(struct clock_event_device *dev,
* A nsec2cyc multiplicator of 0 is invalid and we'd crash * A nsec2cyc multiplicator of 0 is invalid and we'd crash
* on it, so fix it up and emit a warning: * on it, so fix it up and emit a warning:
*/ */
if (state == CLOCK_EVT_STATE_ONESHOT) { if (clockevent_state_oneshot(dev)) {
if (unlikely(!dev->mult)) { if (unlikely(!dev->mult)) {
dev->mult = 1; dev->mult = 1;
WARN_ON(1); WARN_ON(1);
...@@ -259,7 +259,7 @@ static int clockevents_program_min_delta(struct clock_event_device *dev) ...@@ -259,7 +259,7 @@ static int clockevents_program_min_delta(struct clock_event_device *dev)
delta = dev->min_delta_ns; delta = dev->min_delta_ns;
dev->next_event = ktime_add_ns(ktime_get(), delta); dev->next_event = ktime_add_ns(ktime_get(), delta);
if (dev->state == CLOCK_EVT_STATE_SHUTDOWN) if (clockevent_state_shutdown(dev))
return 0; return 0;
dev->retries++; dev->retries++;
...@@ -296,7 +296,7 @@ static int clockevents_program_min_delta(struct clock_event_device *dev) ...@@ -296,7 +296,7 @@ static int clockevents_program_min_delta(struct clock_event_device *dev)
delta = dev->min_delta_ns; delta = dev->min_delta_ns;
dev->next_event = ktime_add_ns(ktime_get(), delta); dev->next_event = ktime_add_ns(ktime_get(), delta);
if (dev->state == CLOCK_EVT_STATE_SHUTDOWN) if (clockevent_state_shutdown(dev))
return 0; return 0;
dev->retries++; dev->retries++;
...@@ -328,11 +328,11 @@ int clockevents_program_event(struct clock_event_device *dev, ktime_t expires, ...@@ -328,11 +328,11 @@ int clockevents_program_event(struct clock_event_device *dev, ktime_t expires,
dev->next_event = expires; dev->next_event = expires;
if (dev->state == CLOCK_EVT_STATE_SHUTDOWN) if (clockevent_state_shutdown(dev))
return 0; return 0;
/* We must be in ONESHOT state here */ /* We must be in ONESHOT state here */
WARN_ONCE(dev->state != CLOCK_EVT_STATE_ONESHOT, "Current state: %d\n", WARN_ONCE(!clockevent_state_oneshot(dev), "Current state: %d\n",
dev->state); dev->state);
/* Shortcut for clockevent devices that can deal with ktime. */ /* Shortcut for clockevent devices that can deal with ktime. */
...@@ -377,7 +377,7 @@ static int clockevents_replace(struct clock_event_device *ced) ...@@ -377,7 +377,7 @@ static int clockevents_replace(struct clock_event_device *ced)
struct clock_event_device *dev, *newdev = NULL; struct clock_event_device *dev, *newdev = NULL;
list_for_each_entry(dev, &clockevent_devices, list) { list_for_each_entry(dev, &clockevent_devices, list) {
if (dev == ced || dev->state != CLOCK_EVT_STATE_DETACHED) if (dev == ced || !clockevent_state_detached(dev))
continue; continue;
if (!tick_check_replacement(newdev, dev)) if (!tick_check_replacement(newdev, dev))
...@@ -403,7 +403,7 @@ static int clockevents_replace(struct clock_event_device *ced) ...@@ -403,7 +403,7 @@ static int clockevents_replace(struct clock_event_device *ced)
static int __clockevents_try_unbind(struct clock_event_device *ced, int cpu) static int __clockevents_try_unbind(struct clock_event_device *ced, int cpu)
{ {
/* Fast track. Device is unused */ /* Fast track. Device is unused */
if (ced->state == CLOCK_EVT_STATE_DETACHED) { if (clockevent_state_detached(ced)) {
list_del_init(&ced->list); list_del_init(&ced->list);
return 0; return 0;
} }
...@@ -561,10 +561,10 @@ int __clockevents_update_freq(struct clock_event_device *dev, u32 freq) ...@@ -561,10 +561,10 @@ int __clockevents_update_freq(struct clock_event_device *dev, u32 freq)
{ {
clockevents_config(dev, freq); clockevents_config(dev, freq);
if (dev->state == CLOCK_EVT_STATE_ONESHOT) if (clockevent_state_oneshot(dev))
return clockevents_program_event(dev, dev->next_event, false); return clockevents_program_event(dev, dev->next_event, false);
if (dev->state == CLOCK_EVT_STATE_PERIODIC) if (clockevent_state_periodic(dev))
return __clockevents_set_state(dev, CLOCK_EVT_STATE_PERIODIC); return __clockevents_set_state(dev, CLOCK_EVT_STATE_PERIODIC);
return 0; return 0;
...@@ -625,7 +625,7 @@ void clockevents_exchange_device(struct clock_event_device *old, ...@@ -625,7 +625,7 @@ void clockevents_exchange_device(struct clock_event_device *old,
} }
if (new) { if (new) {
BUG_ON(new->state != CLOCK_EVT_STATE_DETACHED); BUG_ON(!clockevent_state_detached(new));
clockevents_shutdown(new); clockevents_shutdown(new);
} }
} }
...@@ -681,7 +681,7 @@ void tick_cleanup_dead_cpu(int cpu) ...@@ -681,7 +681,7 @@ void tick_cleanup_dead_cpu(int cpu)
if (cpumask_test_cpu(cpu, dev->cpumask) && if (cpumask_test_cpu(cpu, dev->cpumask) &&
cpumask_weight(dev->cpumask) == 1 && cpumask_weight(dev->cpumask) == 1 &&
!tick_is_broadcast_device(dev)) { !tick_is_broadcast_device(dev)) {
BUG_ON(dev->state != CLOCK_EVT_STATE_DETACHED); BUG_ON(!clockevent_state_detached(dev));
list_del(&dev->list); list_del(&dev->list);
} }
} }
......
...@@ -303,7 +303,7 @@ static void tick_handle_periodic_broadcast(struct clock_event_device *dev) ...@@ -303,7 +303,7 @@ static void tick_handle_periodic_broadcast(struct clock_event_device *dev)
raw_spin_lock(&tick_broadcast_lock); raw_spin_lock(&tick_broadcast_lock);
bc_local = tick_do_periodic_broadcast(); bc_local = tick_do_periodic_broadcast();
if (dev->state == CLOCK_EVT_STATE_ONESHOT) { if (clockevent_state_oneshot(dev)) {
ktime_t next = ktime_add(dev->next_event, tick_period); ktime_t next = ktime_add(dev->next_event, tick_period);
clockevents_program_event(dev, next, true); clockevents_program_event(dev, next, true);
...@@ -528,7 +528,7 @@ static void tick_broadcast_set_affinity(struct clock_event_device *bc, ...@@ -528,7 +528,7 @@ static void tick_broadcast_set_affinity(struct clock_event_device *bc,
static void tick_broadcast_set_event(struct clock_event_device *bc, int cpu, static void tick_broadcast_set_event(struct clock_event_device *bc, int cpu,
ktime_t expires) ktime_t expires)
{ {
if (bc->state != CLOCK_EVT_STATE_ONESHOT) if (!clockevent_state_oneshot(bc))
clockevents_set_state(bc, CLOCK_EVT_STATE_ONESHOT); clockevents_set_state(bc, CLOCK_EVT_STATE_ONESHOT);
clockevents_program_event(bc, expires, 1); clockevents_program_event(bc, expires, 1);
...@@ -831,7 +831,7 @@ void tick_broadcast_setup_oneshot(struct clock_event_device *bc) ...@@ -831,7 +831,7 @@ void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
/* Set it up only once ! */ /* Set it up only once ! */
if (bc->event_handler != tick_handle_oneshot_broadcast) { if (bc->event_handler != tick_handle_oneshot_broadcast) {
int was_periodic = bc->state == CLOCK_EVT_STATE_PERIODIC; int was_periodic = clockevent_state_periodic(bc);
bc->event_handler = tick_handle_oneshot_broadcast; bc->event_handler = tick_handle_oneshot_broadcast;
......
...@@ -112,7 +112,7 @@ void tick_handle_periodic(struct clock_event_device *dev) ...@@ -112,7 +112,7 @@ void tick_handle_periodic(struct clock_event_device *dev)
return; return;
#endif #endif
if (dev->state != CLOCK_EVT_STATE_ONESHOT) if (!clockevent_state_oneshot(dev))
return; return;
for (;;) { for (;;) {
/* /*
......
...@@ -36,7 +36,7 @@ int tick_program_event(ktime_t expires, int force) ...@@ -36,7 +36,7 @@ int tick_program_event(ktime_t expires, int force)
return 0; return 0;
} }
if (unlikely(dev->state == CLOCK_EVT_STATE_ONESHOT_STOPPED)) { if (unlikely(clockevent_state_oneshot_stopped(dev))) {
/* /*
* We need the clock event again, configure it in ONESHOT mode * We need the clock event again, configure it in ONESHOT mode
* before using it. * before using it.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment