Commit d7eb231c authored by Thomas Gleixner's avatar Thomas Gleixner

clockevents: Provide functions to set and get the state

We want to rename dev->state, so provide proper get and set
functions. Rename clockevents_set_state() to
clockevents_switch_state() to avoid confusion.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
parent 472c4a94
...@@ -94,8 +94,8 @@ u64 clockevent_delta2ns(unsigned long latch, struct clock_event_device *evt) ...@@ -94,8 +94,8 @@ u64 clockevent_delta2ns(unsigned long latch, struct clock_event_device *evt)
} }
EXPORT_SYMBOL_GPL(clockevent_delta2ns); EXPORT_SYMBOL_GPL(clockevent_delta2ns);
static int __clockevents_set_state(struct clock_event_device *dev, static int __clockevents_switch_state(struct clock_event_device *dev,
enum clock_event_state state) enum clock_event_state state)
{ {
/* Transition with legacy set_mode() callback */ /* Transition with legacy set_mode() callback */
if (dev->set_mode) { if (dev->set_mode) {
...@@ -151,17 +151,17 @@ static int __clockevents_set_state(struct clock_event_device *dev, ...@@ -151,17 +151,17 @@ static int __clockevents_set_state(struct clock_event_device *dev,
} }
/** /**
* clockevents_set_state - set the operating state of a clock event device * clockevents_switch_state - set the operating state of a clock event device
* @dev: device to modify * @dev: device to modify
* @state: new state * @state: new state
* *
* Must be called with interrupts disabled ! * Must be called with interrupts disabled !
*/ */
void clockevents_set_state(struct clock_event_device *dev, void clockevents_switch_state(struct clock_event_device *dev,
enum clock_event_state state) enum clock_event_state state)
{ {
if (dev->state != state) { if (dev->state != state) {
if (__clockevents_set_state(dev, state)) if (__clockevents_switch_state(dev, state))
return; return;
dev->state = state; dev->state = state;
...@@ -185,7 +185,7 @@ void clockevents_set_state(struct clock_event_device *dev, ...@@ -185,7 +185,7 @@ void clockevents_set_state(struct clock_event_device *dev,
*/ */
void clockevents_shutdown(struct clock_event_device *dev) void clockevents_shutdown(struct clock_event_device *dev)
{ {
clockevents_set_state(dev, CLOCK_EVT_STATE_SHUTDOWN); clockevents_switch_state(dev, CLOCK_EVT_STATE_SHUTDOWN);
dev->next_event.tv64 = KTIME_MAX; dev->next_event.tv64 = KTIME_MAX;
} }
...@@ -565,7 +565,7 @@ int __clockevents_update_freq(struct clock_event_device *dev, u32 freq) ...@@ -565,7 +565,7 @@ int __clockevents_update_freq(struct clock_event_device *dev, u32 freq)
return clockevents_program_event(dev, dev->next_event, false); return clockevents_program_event(dev, dev->next_event, false);
if (clockevent_state_periodic(dev)) if (clockevent_state_periodic(dev))
return __clockevents_set_state(dev, CLOCK_EVT_STATE_PERIODIC); return __clockevents_switch_state(dev, CLOCK_EVT_STATE_PERIODIC);
return 0; return 0;
} }
...@@ -619,7 +619,7 @@ void clockevents_exchange_device(struct clock_event_device *old, ...@@ -619,7 +619,7 @@ void clockevents_exchange_device(struct clock_event_device *old,
*/ */
if (old) { if (old) {
module_put(old->owner); module_put(old->owner);
clockevents_set_state(old, CLOCK_EVT_STATE_DETACHED); clockevents_switch_state(old, CLOCK_EVT_STATE_DETACHED);
list_del(&old->list); list_del(&old->list);
list_add(&old->list, &clockevents_released); list_add(&old->list, &clockevents_released);
} }
......
...@@ -529,7 +529,7 @@ static void tick_broadcast_set_event(struct clock_event_device *bc, int cpu, ...@@ -529,7 +529,7 @@ static void tick_broadcast_set_event(struct clock_event_device *bc, int cpu,
ktime_t expires) ktime_t expires)
{ {
if (!clockevent_state_oneshot(bc)) if (!clockevent_state_oneshot(bc))
clockevents_set_state(bc, CLOCK_EVT_STATE_ONESHOT); clockevents_switch_state(bc, CLOCK_EVT_STATE_ONESHOT);
clockevents_program_event(bc, expires, 1); clockevents_program_event(bc, expires, 1);
tick_broadcast_set_affinity(bc, cpumask_of(cpu)); tick_broadcast_set_affinity(bc, cpumask_of(cpu));
...@@ -537,7 +537,7 @@ static void tick_broadcast_set_event(struct clock_event_device *bc, int cpu, ...@@ -537,7 +537,7 @@ static void tick_broadcast_set_event(struct clock_event_device *bc, int cpu,
static void tick_resume_broadcast_oneshot(struct clock_event_device *bc) static void tick_resume_broadcast_oneshot(struct clock_event_device *bc)
{ {
clockevents_set_state(bc, CLOCK_EVT_STATE_ONESHOT); clockevents_switch_state(bc, CLOCK_EVT_STATE_ONESHOT);
} }
/* /*
...@@ -555,7 +555,7 @@ void tick_check_oneshot_broadcast_this_cpu(void) ...@@ -555,7 +555,7 @@ void tick_check_oneshot_broadcast_this_cpu(void)
* switched over, leave the device alone. * switched over, leave the device alone.
*/ */
if (td->mode == TICKDEV_MODE_ONESHOT) { if (td->mode == TICKDEV_MODE_ONESHOT) {
clockevents_set_state(td->evtdev, clockevents_switch_state(td->evtdev,
CLOCK_EVT_STATE_ONESHOT); CLOCK_EVT_STATE_ONESHOT);
} }
} }
...@@ -659,7 +659,7 @@ static void broadcast_shutdown_local(struct clock_event_device *bc, ...@@ -659,7 +659,7 @@ static void broadcast_shutdown_local(struct clock_event_device *bc,
if (dev->next_event.tv64 < bc->next_event.tv64) if (dev->next_event.tv64 < bc->next_event.tv64)
return; return;
} }
clockevents_set_state(dev, CLOCK_EVT_STATE_SHUTDOWN); clockevents_switch_state(dev, CLOCK_EVT_STATE_SHUTDOWN);
} }
/** /**
...@@ -729,7 +729,7 @@ int tick_broadcast_oneshot_control(enum tick_broadcast_state state) ...@@ -729,7 +729,7 @@ int tick_broadcast_oneshot_control(enum tick_broadcast_state state)
cpumask_clear_cpu(cpu, tick_broadcast_oneshot_mask); cpumask_clear_cpu(cpu, tick_broadcast_oneshot_mask);
} else { } else {
if (cpumask_test_and_clear_cpu(cpu, tick_broadcast_oneshot_mask)) { if (cpumask_test_and_clear_cpu(cpu, tick_broadcast_oneshot_mask)) {
clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT); clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT);
/* /*
* The cpu which was handling the broadcast * The cpu which was handling the broadcast
* timer marked this cpu in the broadcast * timer marked this cpu in the broadcast
...@@ -847,7 +847,7 @@ void tick_broadcast_setup_oneshot(struct clock_event_device *bc) ...@@ -847,7 +847,7 @@ void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
tick_broadcast_oneshot_mask, tmpmask); tick_broadcast_oneshot_mask, tmpmask);
if (was_periodic && !cpumask_empty(tmpmask)) { if (was_periodic && !cpumask_empty(tmpmask)) {
clockevents_set_state(bc, CLOCK_EVT_STATE_ONESHOT); clockevents_switch_state(bc, CLOCK_EVT_STATE_ONESHOT);
tick_broadcast_init_next_event(tmpmask, tick_broadcast_init_next_event(tmpmask,
tick_next_period); tick_next_period);
tick_broadcast_set_event(bc, cpu, tick_next_period); tick_broadcast_set_event(bc, cpu, tick_next_period);
......
...@@ -150,7 +150,7 @@ void tick_setup_periodic(struct clock_event_device *dev, int broadcast) ...@@ -150,7 +150,7 @@ void tick_setup_periodic(struct clock_event_device *dev, int broadcast)
if ((dev->features & CLOCK_EVT_FEAT_PERIODIC) && if ((dev->features & CLOCK_EVT_FEAT_PERIODIC) &&
!tick_broadcast_oneshot_active()) { !tick_broadcast_oneshot_active()) {
clockevents_set_state(dev, CLOCK_EVT_STATE_PERIODIC); clockevents_switch_state(dev, CLOCK_EVT_STATE_PERIODIC);
} else { } else {
unsigned long seq; unsigned long seq;
ktime_t next; ktime_t next;
...@@ -160,7 +160,7 @@ void tick_setup_periodic(struct clock_event_device *dev, int broadcast) ...@@ -160,7 +160,7 @@ void tick_setup_periodic(struct clock_event_device *dev, int broadcast)
next = tick_next_period; next = tick_next_period;
} while (read_seqretry(&jiffies_lock, seq)); } while (read_seqretry(&jiffies_lock, seq));
clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT); clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT);
for (;;) { for (;;) {
if (!clockevents_program_event(dev, next, false)) if (!clockevents_program_event(dev, next, false))
......
...@@ -36,11 +36,22 @@ static inline int tick_device_is_functional(struct clock_event_device *dev) ...@@ -36,11 +36,22 @@ static inline int tick_device_is_functional(struct clock_event_device *dev)
return !(dev->features & CLOCK_EVT_FEAT_DUMMY); return !(dev->features & CLOCK_EVT_FEAT_DUMMY);
} }
static inline enum clock_event_state clockevent_get_state(struct clock_event_device *dev)
{
return dev->state;
}
static inline void clockevent_set_state(struct clock_event_device *dev,
enum clock_event_state state)
{
dev->state = state;
}
extern void clockevents_shutdown(struct clock_event_device *dev); extern void clockevents_shutdown(struct clock_event_device *dev);
extern void clockevents_exchange_device(struct clock_event_device *old, extern void clockevents_exchange_device(struct clock_event_device *old,
struct clock_event_device *new); struct clock_event_device *new);
extern void clockevents_set_state(struct clock_event_device *dev, extern void clockevents_switch_state(struct clock_event_device *dev,
enum clock_event_state state); enum clock_event_state state);
extern int clockevents_program_event(struct clock_event_device *dev, extern int clockevents_program_event(struct clock_event_device *dev,
ktime_t expires, bool force); ktime_t expires, bool force);
extern void clockevents_handle_noop(struct clock_event_device *dev); extern void clockevents_handle_noop(struct clock_event_device *dev);
......
...@@ -32,7 +32,7 @@ int tick_program_event(ktime_t expires, int force) ...@@ -32,7 +32,7 @@ int tick_program_event(ktime_t expires, int force)
/* /*
* We don't need the clock event device any more, stop it. * We don't need the clock event device any more, stop it.
*/ */
clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT_STOPPED); clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT_STOPPED);
return 0; return 0;
} }
...@@ -41,7 +41,7 @@ int tick_program_event(ktime_t expires, int force) ...@@ -41,7 +41,7 @@ int tick_program_event(ktime_t expires, int force)
* 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.
*/ */
clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT); clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT);
} }
return clockevents_program_event(dev, expires, force); return clockevents_program_event(dev, expires, force);
...@@ -54,7 +54,7 @@ void tick_resume_oneshot(void) ...@@ -54,7 +54,7 @@ void tick_resume_oneshot(void)
{ {
struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev); struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev);
clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT); clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT);
clockevents_program_event(dev, ktime_get(), true); clockevents_program_event(dev, ktime_get(), true);
} }
...@@ -66,7 +66,7 @@ void tick_setup_oneshot(struct clock_event_device *newdev, ...@@ -66,7 +66,7 @@ void tick_setup_oneshot(struct clock_event_device *newdev,
ktime_t next_event) ktime_t next_event)
{ {
newdev->event_handler = handler; newdev->event_handler = handler;
clockevents_set_state(newdev, CLOCK_EVT_STATE_ONESHOT); clockevents_switch_state(newdev, CLOCK_EVT_STATE_ONESHOT);
clockevents_program_event(newdev, next_event, true); clockevents_program_event(newdev, next_event, true);
} }
...@@ -97,7 +97,7 @@ int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *)) ...@@ -97,7 +97,7 @@ int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *))
td->mode = TICKDEV_MODE_ONESHOT; td->mode = TICKDEV_MODE_ONESHOT;
dev->event_handler = handler; dev->event_handler = handler;
clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT); clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT);
tick_broadcast_switch_to_oneshot(); tick_broadcast_switch_to_oneshot();
return 0; return 0;
} }
......
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