clockevents: Provide functions to set and get the state
authorThomas Gleixner <tglx@linutronix.de>
Tue, 2 Jun 2015 12:08:46 +0000 (14:08 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 2 Jun 2015 12:40:47 +0000 (14:40 +0200)
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: Thomas Gleixner <tglx@linutronix.de>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
kernel/time/clockevents.c
kernel/time/tick-broadcast.c
kernel/time/tick-common.c
kernel/time/tick-internal.h
kernel/time/tick-oneshot.c

index e568ec8c320ba8eb255c91c2dcb983933814a590..a45f90c4b2d573e21dd4d5a80924211f43f82680 100644 (file)
@@ -94,8 +94,8 @@ u64 clockevent_delta2ns(unsigned long latch, struct clock_event_device *evt)
 }
 EXPORT_SYMBOL_GPL(clockevent_delta2ns);
 
-static int __clockevents_set_state(struct clock_event_device *dev,
-                                  enum clock_event_state state)
+static int __clockevents_switch_state(struct clock_event_device *dev,
+                                     enum clock_event_state state)
 {
        /* Transition with legacy set_mode() callback */
        if (dev->set_mode) {
@@ -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
  * @state:     new state
  *
  * Must be called with interrupts disabled !
  */
-void clockevents_set_state(struct clock_event_device *dev,
-                          enum clock_event_state state)
+void clockevents_switch_state(struct clock_event_device *dev,
+                             enum clock_event_state state)
 {
        if (dev->state != state) {
-               if (__clockevents_set_state(dev, state))
+               if (__clockevents_switch_state(dev, state))
                        return;
 
                dev->state = state;
@@ -185,7 +185,7 @@ void clockevents_set_state(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;
 }
 
@@ -565,7 +565,7 @@ int __clockevents_update_freq(struct clock_event_device *dev, u32 freq)
                return clockevents_program_event(dev, dev->next_event, false);
 
        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;
 }
@@ -619,7 +619,7 @@ void clockevents_exchange_device(struct clock_event_device *old,
         */
        if (old) {
                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_add(&old->list, &clockevents_released);
        }
index 132f819fdcdfb25e7140f6634d5a6b7bcaf0d623..d39f32cdd1b59cca97066430442e3aa054cc9eed 100644 (file)
@@ -529,7 +529,7 @@ static void tick_broadcast_set_event(struct clock_event_device *bc, int cpu,
                                     ktime_t expires)
 {
        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);
        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,
 
 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)
                 * switched over, leave the device alone.
                 */
                if (td->mode == TICKDEV_MODE_ONESHOT) {
-                       clockevents_set_state(td->evtdev,
+                       clockevents_switch_state(td->evtdev,
                                              CLOCK_EVT_STATE_ONESHOT);
                }
        }
@@ -659,7 +659,7 @@ static void broadcast_shutdown_local(struct clock_event_device *bc,
                if (dev->next_event.tv64 < bc->next_event.tv64)
                        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)
                        cpumask_clear_cpu(cpu, tick_broadcast_oneshot_mask);
        } else {
                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
                         * timer marked this cpu in the broadcast
@@ -847,7 +847,7 @@ void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
                           tick_broadcast_oneshot_mask, 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_next_period);
                        tick_broadcast_set_event(bc, cpu, tick_next_period);
index cf881c62c3c5e8d94ee24084f18eda570908880f..311e2e133517de641f9f5d7834e031cb061f80f1 100644 (file)
@@ -150,7 +150,7 @@ void tick_setup_periodic(struct clock_event_device *dev, int broadcast)
 
        if ((dev->features & CLOCK_EVT_FEAT_PERIODIC) &&
            !tick_broadcast_oneshot_active()) {
-               clockevents_set_state(dev, CLOCK_EVT_STATE_PERIODIC);
+               clockevents_switch_state(dev, CLOCK_EVT_STATE_PERIODIC);
        } else {
                unsigned long seq;
                ktime_t next;
@@ -160,7 +160,7 @@ void tick_setup_periodic(struct clock_event_device *dev, int broadcast)
                        next = tick_next_period;
                } while (read_seqretry(&jiffies_lock, seq));
 
-               clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT);
+               clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT);
 
                for (;;) {
                        if (!clockevents_program_event(dev, next, false))
index 65273f0a11ed34d90ceb03a5061b6a1510e3220d..4461de9bb4b83114fb53e3bdcfea96ee5ceb2c78 100644 (file)
@@ -36,11 +36,22 @@ static inline int tick_device_is_functional(struct clock_event_device *dev)
        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_exchange_device(struct clock_event_device *old,
                                        struct clock_event_device *new);
-extern void clockevents_set_state(struct clock_event_device *dev,
-                                enum clock_event_state state);
+extern void clockevents_switch_state(struct clock_event_device *dev,
+                                    enum clock_event_state state);
 extern int clockevents_program_event(struct clock_event_device *dev,
                                     ktime_t expires, bool force);
 extern void clockevents_handle_noop(struct clock_event_device *dev);
index 3f9715bec2910aef445bcbf75f1fbaea8af72097..b51344652330a2b12ebb4e72875515a791a8270f 100644 (file)
@@ -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.
                 */
-               clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT_STOPPED);
+               clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT_STOPPED);
                return 0;
        }
 
@@ -41,7 +41,7 @@ int tick_program_event(ktime_t expires, int force)
                 * We need the clock event again, configure it in ONESHOT mode
                 * 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);
@@ -54,7 +54,7 @@ void tick_resume_oneshot(void)
 {
        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);
 }
 
@@ -66,7 +66,7 @@ void tick_setup_oneshot(struct clock_event_device *newdev,
                        ktime_t next_event)
 {
        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);
 }
 
@@ -97,7 +97,7 @@ int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *))
 
        td->mode = TICKDEV_MODE_ONESHOT;
        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();
        return 0;
 }