Skip to content

Commit d7eb231

Browse files
committed
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>
1 parent 472c4a9 commit d7eb231

5 files changed

Lines changed: 35 additions & 24 deletions

File tree

‎kernel/time/clockevents.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ u64 clockevent_delta2ns(unsigned long latch, struct clock_event_device *evt)
9494
}
9595
EXPORT_SYMBOL_GPL(clockevent_delta2ns);
9696

97-
static int __clockevents_set_state(struct clock_event_device *dev,
98-
enum clock_event_state state)
97+
static int __clockevents_switch_state(struct clock_event_device *dev,
98+
enum clock_event_state state)
9999
{
100100
/* Transition with legacy set_mode() callback */
101101
if (dev->set_mode) {
@@ -151,17 +151,17 @@ static int __clockevents_set_state(struct clock_event_device *dev,
151151
}
152152

153153
/**
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
155155
* @dev: device to modify
156156
* @state: new state
157157
*
158158
* Must be called with interrupts disabled !
159159
*/
160-
void clockevents_set_state(struct clock_event_device *dev,
161-
enum clock_event_state state)
160+
void clockevents_switch_state(struct clock_event_device *dev,
161+
enum clock_event_state state)
162162
{
163163
if (dev->state != state) {
164-
if (__clockevents_set_state(dev, state))
164+
if (__clockevents_switch_state(dev, state))
165165
return;
166166

167167
dev->state = state;
@@ -185,7 +185,7 @@ void clockevents_set_state(struct clock_event_device *dev,
185185
*/
186186
void clockevents_shutdown(struct clock_event_device *dev)
187187
{
188-
clockevents_set_state(dev, CLOCK_EVT_STATE_SHUTDOWN);
188+
clockevents_switch_state(dev, CLOCK_EVT_STATE_SHUTDOWN);
189189
dev->next_event.tv64 = KTIME_MAX;
190190
}
191191

@@ -565,7 +565,7 @@ int __clockevents_update_freq(struct clock_event_device *dev, u32 freq)
565565
return clockevents_program_event(dev, dev->next_event, false);
566566

567567
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);
569569

570570
return 0;
571571
}
@@ -619,7 +619,7 @@ void clockevents_exchange_device(struct clock_event_device *old,
619619
*/
620620
if (old) {
621621
module_put(old->owner);
622-
clockevents_set_state(old, CLOCK_EVT_STATE_DETACHED);
622+
clockevents_switch_state(old, CLOCK_EVT_STATE_DETACHED);
623623
list_del(&old->list);
624624
list_add(&old->list, &clockevents_released);
625625
}

‎kernel/time/tick-broadcast.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -529,15 +529,15 @@ static void tick_broadcast_set_event(struct clock_event_device *bc, int cpu,
529529
ktime_t expires)
530530
{
531531
if (!clockevent_state_oneshot(bc))
532-
clockevents_set_state(bc, CLOCK_EVT_STATE_ONESHOT);
532+
clockevents_switch_state(bc, CLOCK_EVT_STATE_ONESHOT);
533533

534534
clockevents_program_event(bc, expires, 1);
535535
tick_broadcast_set_affinity(bc, cpumask_of(cpu));
536536
}
537537

538538
static void tick_resume_broadcast_oneshot(struct clock_event_device *bc)
539539
{
540-
clockevents_set_state(bc, CLOCK_EVT_STATE_ONESHOT);
540+
clockevents_switch_state(bc, CLOCK_EVT_STATE_ONESHOT);
541541
}
542542

543543
/*
@@ -555,7 +555,7 @@ void tick_check_oneshot_broadcast_this_cpu(void)
555555
* switched over, leave the device alone.
556556
*/
557557
if (td->mode == TICKDEV_MODE_ONESHOT) {
558-
clockevents_set_state(td->evtdev,
558+
clockevents_switch_state(td->evtdev,
559559
CLOCK_EVT_STATE_ONESHOT);
560560
}
561561
}
@@ -659,7 +659,7 @@ static void broadcast_shutdown_local(struct clock_event_device *bc,
659659
if (dev->next_event.tv64 < bc->next_event.tv64)
660660
return;
661661
}
662-
clockevents_set_state(dev, CLOCK_EVT_STATE_SHUTDOWN);
662+
clockevents_switch_state(dev, CLOCK_EVT_STATE_SHUTDOWN);
663663
}
664664

665665
/**
@@ -729,7 +729,7 @@ int tick_broadcast_oneshot_control(enum tick_broadcast_state state)
729729
cpumask_clear_cpu(cpu, tick_broadcast_oneshot_mask);
730730
} else {
731731
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);
733733
/*
734734
* The cpu which was handling the broadcast
735735
* timer marked this cpu in the broadcast
@@ -847,7 +847,7 @@ void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
847847
tick_broadcast_oneshot_mask, tmpmask);
848848

849849
if (was_periodic && !cpumask_empty(tmpmask)) {
850-
clockevents_set_state(bc, CLOCK_EVT_STATE_ONESHOT);
850+
clockevents_switch_state(bc, CLOCK_EVT_STATE_ONESHOT);
851851
tick_broadcast_init_next_event(tmpmask,
852852
tick_next_period);
853853
tick_broadcast_set_event(bc, cpu, tick_next_period);

‎kernel/time/tick-common.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void tick_setup_periodic(struct clock_event_device *dev, int broadcast)
150150

151151
if ((dev->features & CLOCK_EVT_FEAT_PERIODIC) &&
152152
!tick_broadcast_oneshot_active()) {
153-
clockevents_set_state(dev, CLOCK_EVT_STATE_PERIODIC);
153+
clockevents_switch_state(dev, CLOCK_EVT_STATE_PERIODIC);
154154
} else {
155155
unsigned long seq;
156156
ktime_t next;
@@ -160,7 +160,7 @@ void tick_setup_periodic(struct clock_event_device *dev, int broadcast)
160160
next = tick_next_period;
161161
} while (read_seqretry(&jiffies_lock, seq));
162162

163-
clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT);
163+
clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT);
164164

165165
for (;;) {
166166
if (!clockevents_program_event(dev, next, false))

‎kernel/time/tick-internal.h‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,22 @@ static inline int tick_device_is_functional(struct clock_event_device *dev)
3636
return !(dev->features & CLOCK_EVT_FEAT_DUMMY);
3737
}
3838

39+
static inline enum clock_event_state clockevent_get_state(struct clock_event_device *dev)
40+
{
41+
return dev->state;
42+
}
43+
44+
static inline void clockevent_set_state(struct clock_event_device *dev,
45+
enum clock_event_state state)
46+
{
47+
dev->state = state;
48+
}
49+
3950
extern void clockevents_shutdown(struct clock_event_device *dev);
4051
extern void clockevents_exchange_device(struct clock_event_device *old,
4152
struct clock_event_device *new);
42-
extern void clockevents_set_state(struct clock_event_device *dev,
43-
enum clock_event_state state);
53+
extern void clockevents_switch_state(struct clock_event_device *dev,
54+
enum clock_event_state state);
4455
extern int clockevents_program_event(struct clock_event_device *dev,
4556
ktime_t expires, bool force);
4657
extern void clockevents_handle_noop(struct clock_event_device *dev);

‎kernel/time/tick-oneshot.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ int tick_program_event(ktime_t expires, int force)
3232
/*
3333
* We don't need the clock event device any more, stop it.
3434
*/
35-
clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT_STOPPED);
35+
clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT_STOPPED);
3636
return 0;
3737
}
3838

@@ -41,7 +41,7 @@ int tick_program_event(ktime_t expires, int force)
4141
* We need the clock event again, configure it in ONESHOT mode
4242
* before using it.
4343
*/
44-
clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT);
44+
clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT);
4545
}
4646

4747
return clockevents_program_event(dev, expires, force);
@@ -54,7 +54,7 @@ void tick_resume_oneshot(void)
5454
{
5555
struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev);
5656

57-
clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT);
57+
clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT);
5858
clockevents_program_event(dev, ktime_get(), true);
5959
}
6060

@@ -66,7 +66,7 @@ void tick_setup_oneshot(struct clock_event_device *newdev,
6666
ktime_t next_event)
6767
{
6868
newdev->event_handler = handler;
69-
clockevents_set_state(newdev, CLOCK_EVT_STATE_ONESHOT);
69+
clockevents_switch_state(newdev, CLOCK_EVT_STATE_ONESHOT);
7070
clockevents_program_event(newdev, next_event, true);
7171
}
7272

@@ -97,7 +97,7 @@ int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *))
9797

9898
td->mode = TICKDEV_MODE_ONESHOT;
9999
dev->event_handler = handler;
100-
clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT);
100+
clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT);
101101
tick_broadcast_switch_to_oneshot();
102102
return 0;
103103
}

0 commit comments

Comments
 (0)