aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2015-06-02 08:08:46 -0400
committerThomas Gleixner <tglx@linutronix.de>2015-06-02 08:40:47 -0400
commitd7eb231c71420bc34ac3d35403115600f920cfc2 (patch)
tree6368b8933cfa40786ecea7afa7999b0390f333dd
parent472c4a9437d3c6a0b1e59df7c5aa14075946aa70 (diff)
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: Thomas Gleixner <tglx@linutronix.de> Cc: Viresh Kumar <viresh.kumar@linaro.org> Cc: Peter Zijlstra <peterz@infradead.org>
-rw-r--r--kernel/time/clockevents.c18
-rw-r--r--kernel/time/tick-broadcast.c12
-rw-r--r--kernel/time/tick-common.c4
-rw-r--r--kernel/time/tick-internal.h15
-rw-r--r--kernel/time/tick-oneshot.c10
5 files changed, 35 insertions, 24 deletions
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index e568ec8c320b..a45f90c4b2d5 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -94,8 +94,8 @@ u64 clockevent_delta2ns(unsigned long latch, struct clock_event_device *evt)
94} 94}
95EXPORT_SYMBOL_GPL(clockevent_delta2ns); 95EXPORT_SYMBOL_GPL(clockevent_delta2ns);
96 96
97static int __clockevents_set_state(struct clock_event_device *dev, 97static int __clockevents_switch_state(struct clock_event_device *dev,
98 enum clock_event_state state) 98 enum clock_event_state state)
99{ 99{
100 /* Transition with legacy set_mode() callback */ 100 /* Transition with legacy set_mode() callback */
101 if (dev->set_mode) { 101 if (dev->set_mode) {
@@ -151,17 +151,17 @@ static int __clockevents_set_state(struct clock_event_device *dev,
151} 151}
152 152
153/** 153/**
154 * clockevents_set_state - set the operating state of a clock event device 154 * clockevents_switch_state - set the operating state of a clock event device
155 * @dev: device to modify 155 * @dev: device to modify
156 * @state: new state 156 * @state: new state
157 * 157 *
158 * Must be called with interrupts disabled ! 158 * Must be called with interrupts disabled !
159 */ 159 */
160void clockevents_set_state(struct clock_event_device *dev, 160void clockevents_switch_state(struct clock_event_device *dev,
161 enum clock_event_state state) 161 enum clock_event_state state)
162{ 162{
163 if (dev->state != state) { 163 if (dev->state != state) {
164 if (__clockevents_set_state(dev, state)) 164 if (__clockevents_switch_state(dev, state))
165 return; 165 return;
166 166
167 dev->state = state; 167 dev->state = state;
@@ -185,7 +185,7 @@ void clockevents_set_state(struct clock_event_device *dev,
185 */ 185 */
186void clockevents_shutdown(struct clock_event_device *dev) 186void clockevents_shutdown(struct clock_event_device *dev)
187{ 187{
188 clockevents_set_state(dev, CLOCK_EVT_STATE_SHUTDOWN); 188 clockevents_switch_state(dev, CLOCK_EVT_STATE_SHUTDOWN);
189 dev->next_event.tv64 = KTIME_MAX; 189 dev->next_event.tv64 = KTIME_MAX;
190} 190}
191 191
@@ -565,7 +565,7 @@ int __clockevents_update_freq(struct clock_event_device *dev, u32 freq)
565 return clockevents_program_event(dev, dev->next_event, false); 565 return clockevents_program_event(dev, dev->next_event, false);
566 566
567 if (clockevent_state_periodic(dev)) 567 if (clockevent_state_periodic(dev))
568 return __clockevents_set_state(dev, CLOCK_EVT_STATE_PERIODIC); 568 return __clockevents_switch_state(dev, CLOCK_EVT_STATE_PERIODIC);
569 569
570 return 0; 570 return 0;
571} 571}
@@ -619,7 +619,7 @@ void clockevents_exchange_device(struct clock_event_device *old,
619 */ 619 */
620 if (old) { 620 if (old) {
621 module_put(old->owner); 621 module_put(old->owner);
622 clockevents_set_state(old, CLOCK_EVT_STATE_DETACHED); 622 clockevents_switch_state(old, CLOCK_EVT_STATE_DETACHED);
623 list_del(&old->list); 623 list_del(&old->list);
624 list_add(&old->list, &clockevents_released); 624 list_add(&old->list, &clockevents_released);
625 } 625 }
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index 132f819fdcdf..d39f32cdd1b5 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -529,7 +529,7 @@ static void tick_broadcast_set_event(struct clock_event_device *bc, int cpu,
529 ktime_t expires) 529 ktime_t expires)
530{ 530{
531 if (!clockevent_state_oneshot(bc)) 531 if (!clockevent_state_oneshot(bc))
532 clockevents_set_state(bc, CLOCK_EVT_STATE_ONESHOT); 532 clockevents_switch_state(bc, CLOCK_EVT_STATE_ONESHOT);
533 533
534 clockevents_program_event(bc, expires, 1); 534 clockevents_program_event(bc, expires, 1);
535 tick_broadcast_set_affinity(bc, cpumask_of(cpu)); 535 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 537
538static void tick_resume_broadcast_oneshot(struct clock_event_device *bc) 538static void tick_resume_broadcast_oneshot(struct clock_event_device *bc)
539{ 539{
540 clockevents_set_state(bc, CLOCK_EVT_STATE_ONESHOT); 540 clockevents_switch_state(bc, CLOCK_EVT_STATE_ONESHOT);
541} 541}
542 542
543/* 543/*
@@ -555,7 +555,7 @@ void tick_check_oneshot_broadcast_this_cpu(void)
555 * switched over, leave the device alone. 555 * switched over, leave the device alone.
556 */ 556 */
557 if (td->mode == TICKDEV_MODE_ONESHOT) { 557 if (td->mode == TICKDEV_MODE_ONESHOT) {
558 clockevents_set_state(td->evtdev, 558 clockevents_switch_state(td->evtdev,
559 CLOCK_EVT_STATE_ONESHOT); 559 CLOCK_EVT_STATE_ONESHOT);
560 } 560 }
561 } 561 }
@@ -659,7 +659,7 @@ static void broadcast_shutdown_local(struct clock_event_device *bc,
659 if (dev->next_event.tv64 < bc->next_event.tv64) 659 if (dev->next_event.tv64 < bc->next_event.tv64)
660 return; 660 return;
661 } 661 }
662 clockevents_set_state(dev, CLOCK_EVT_STATE_SHUTDOWN); 662 clockevents_switch_state(dev, CLOCK_EVT_STATE_SHUTDOWN);
663} 663}
664 664
665/** 665/**
@@ -729,7 +729,7 @@ int tick_broadcast_oneshot_control(enum tick_broadcast_state state)
729 cpumask_clear_cpu(cpu, tick_broadcast_oneshot_mask); 729 cpumask_clear_cpu(cpu, tick_broadcast_oneshot_mask);
730 } else { 730 } else {
731 if (cpumask_test_and_clear_cpu(cpu, tick_broadcast_oneshot_mask)) { 731 if (cpumask_test_and_clear_cpu(cpu, tick_broadcast_oneshot_mask)) {
732 clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT); 732 clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT);
733 /* 733 /*
734 * The cpu which was handling the broadcast 734 * The cpu which was handling the broadcast
735 * timer marked this cpu in the broadcast 735 * timer marked this cpu in the broadcast
@@ -847,7 +847,7 @@ void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
847 tick_broadcast_oneshot_mask, tmpmask); 847 tick_broadcast_oneshot_mask, tmpmask);
848 848
849 if (was_periodic && !cpumask_empty(tmpmask)) { 849 if (was_periodic && !cpumask_empty(tmpmask)) {
850 clockevents_set_state(bc, CLOCK_EVT_STATE_ONESHOT); 850 clockevents_switch_state(bc, CLOCK_EVT_STATE_ONESHOT);
851 tick_broadcast_init_next_event(tmpmask, 851 tick_broadcast_init_next_event(tmpmask,
852 tick_next_period); 852 tick_next_period);
853 tick_broadcast_set_event(bc, cpu, tick_next_period); 853 tick_broadcast_set_event(bc, cpu, tick_next_period);
diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
index cf881c62c3c5..311e2e133517 100644
--- a/kernel/time/tick-common.c
+++ b/kernel/time/tick-common.c
@@ -150,7 +150,7 @@ void tick_setup_periodic(struct clock_event_device *dev, int broadcast)
150 150
151 if ((dev->features & CLOCK_EVT_FEAT_PERIODIC) && 151 if ((dev->features & CLOCK_EVT_FEAT_PERIODIC) &&
152 !tick_broadcast_oneshot_active()) { 152 !tick_broadcast_oneshot_active()) {
153 clockevents_set_state(dev, CLOCK_EVT_STATE_PERIODIC); 153 clockevents_switch_state(dev, CLOCK_EVT_STATE_PERIODIC);
154 } else { 154 } else {
155 unsigned long seq; 155 unsigned long seq;
156 ktime_t next; 156 ktime_t next;
@@ -160,7 +160,7 @@ void tick_setup_periodic(struct clock_event_device *dev, int broadcast)
160 next = tick_next_period; 160 next = tick_next_period;
161 } while (read_seqretry(&jiffies_lock, seq)); 161 } while (read_seqretry(&jiffies_lock, seq));
162 162
163 clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT); 163 clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT);
164 164
165 for (;;) { 165 for (;;) {
166 if (!clockevents_program_event(dev, next, false)) 166 if (!clockevents_program_event(dev, next, false))
diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h
index 65273f0a11ed..4461de9bb4b8 100644
--- a/kernel/time/tick-internal.h
+++ b/kernel/time/tick-internal.h
@@ -36,11 +36,22 @@ static inline int tick_device_is_functional(struct clock_event_device *dev)
36 return !(dev->features & CLOCK_EVT_FEAT_DUMMY); 36 return !(dev->features & CLOCK_EVT_FEAT_DUMMY);
37} 37}
38 38
39static inline enum clock_event_state clockevent_get_state(struct clock_event_device *dev)
40{
41 return dev->state;
42}
43
44static inline void clockevent_set_state(struct clock_event_device *dev,
45 enum clock_event_state state)
46{
47 dev->state = state;
48}
49
39extern void clockevents_shutdown(struct clock_event_device *dev); 50extern void clockevents_shutdown(struct clock_event_device *dev);
40extern void clockevents_exchange_device(struct clock_event_device *old, 51extern void clockevents_exchange_device(struct clock_event_device *old,
41 struct clock_event_device *new); 52 struct clock_event_device *new);
42extern void clockevents_set_state(struct clock_event_device *dev, 53extern void clockevents_switch_state(struct clock_event_device *dev,
43 enum clock_event_state state); 54 enum clock_event_state state);
44extern int clockevents_program_event(struct clock_event_device *dev, 55extern int clockevents_program_event(struct clock_event_device *dev,
45 ktime_t expires, bool force); 56 ktime_t expires, bool force);
46extern void clockevents_handle_noop(struct clock_event_device *dev); 57extern void clockevents_handle_noop(struct clock_event_device *dev);
diff --git a/kernel/time/tick-oneshot.c b/kernel/time/tick-oneshot.c
index 3f9715bec291..b51344652330 100644
--- a/kernel/time/tick-oneshot.c
+++ b/kernel/time/tick-oneshot.c
@@ -32,7 +32,7 @@ int tick_program_event(ktime_t expires, int force)
32 /* 32 /*
33 * We don't need the clock event device any more, stop it. 33 * We don't need the clock event device any more, stop it.
34 */ 34 */
35 clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT_STOPPED); 35 clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT_STOPPED);
36 return 0; 36 return 0;
37 } 37 }
38 38
@@ -41,7 +41,7 @@ int tick_program_event(ktime_t expires, int force)
41 * We need the clock event again, configure it in ONESHOT mode 41 * We need the clock event again, configure it in ONESHOT mode
42 * before using it. 42 * before using it.
43 */ 43 */
44 clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT); 44 clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT);
45 } 45 }
46 46
47 return clockevents_program_event(dev, expires, force); 47 return clockevents_program_event(dev, expires, force);
@@ -54,7 +54,7 @@ void tick_resume_oneshot(void)
54{ 54{
55 struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev); 55 struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev);
56 56
57 clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT); 57 clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT);
58 clockevents_program_event(dev, ktime_get(), true); 58 clockevents_program_event(dev, ktime_get(), true);
59} 59}
60 60
@@ -66,7 +66,7 @@ void tick_setup_oneshot(struct clock_event_device *newdev,
66 ktime_t next_event) 66 ktime_t next_event)
67{ 67{
68 newdev->event_handler = handler; 68 newdev->event_handler = handler;
69 clockevents_set_state(newdev, CLOCK_EVT_STATE_ONESHOT); 69 clockevents_switch_state(newdev, CLOCK_EVT_STATE_ONESHOT);
70 clockevents_program_event(newdev, next_event, true); 70 clockevents_program_event(newdev, next_event, true);
71} 71}
72 72
@@ -97,7 +97,7 @@ int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *))
97 97
98 td->mode = TICKDEV_MODE_ONESHOT; 98 td->mode = TICKDEV_MODE_ONESHOT;
99 dev->event_handler = handler; 99 dev->event_handler = handler;
100 clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT); 100 clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT);
101 tick_broadcast_switch_to_oneshot(); 101 tick_broadcast_switch_to_oneshot();
102 return 0; 102 return 0;
103} 103}