Skip to content

Commit 8f9327c

Browse files
vireshkdlezcano
authored andcommitted
clockevents/drivers/cs5535: Migrate to new 'set-state' interface
Migrate cs5535 driver to the new 'set-state' interface provided by the clockevents core, the earlier 'set-mode' interface is marked obsolete now. This also enables us to implement callbacks for new states of clockevent devices, for example: ONESHOT_STOPPED. Acked-by: Daniel Lezcano <[email protected]> Cc: Andres Salomon <[email protected]> Signed-off-by: Viresh Kumar <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]>
1 parent b4cf5d7 commit 8f9327c

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

drivers/clocksource/cs5535-clockevt.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ MODULE_PARM_DESC(irq, "Which IRQ to use for the clock source MFGPT ticks.");
4242
* 256 128 .125 512.000
4343
*/
4444

45-
static unsigned int cs5535_tick_mode = CLOCK_EVT_MODE_SHUTDOWN;
4645
static struct cs5535_mfgpt_timer *cs5535_event_clock;
4746

4847
/* Selected from the table above */
@@ -77,15 +76,17 @@ static void start_timer(struct cs5535_mfgpt_timer *timer, uint16_t delta)
7776
MFGPT_SETUP_CNTEN | MFGPT_SETUP_CMP2);
7877
}
7978

80-
static void mfgpt_set_mode(enum clock_event_mode mode,
81-
struct clock_event_device *evt)
79+
static int mfgpt_shutdown(struct clock_event_device *evt)
8280
{
8381
disable_timer(cs5535_event_clock);
82+
return 0;
83+
}
8484

85-
if (mode == CLOCK_EVT_MODE_PERIODIC)
86-
start_timer(cs5535_event_clock, MFGPT_PERIODIC);
87-
88-
cs5535_tick_mode = mode;
85+
static int mfgpt_set_periodic(struct clock_event_device *evt)
86+
{
87+
disable_timer(cs5535_event_clock);
88+
start_timer(cs5535_event_clock, MFGPT_PERIODIC);
89+
return 0;
8990
}
9091

9192
static int mfgpt_next_event(unsigned long delta, struct clock_event_device *evt)
@@ -97,7 +98,10 @@ static int mfgpt_next_event(unsigned long delta, struct clock_event_device *evt)
9798
static struct clock_event_device cs5535_clockevent = {
9899
.name = DRV_NAME,
99100
.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
100-
.set_mode = mfgpt_set_mode,
101+
.set_state_shutdown = mfgpt_shutdown,
102+
.set_state_periodic = mfgpt_set_periodic,
103+
.set_state_oneshot = mfgpt_shutdown,
104+
.tick_resume = mfgpt_shutdown,
101105
.set_next_event = mfgpt_next_event,
102106
.rating = 250,
103107
};
@@ -113,15 +117,15 @@ static irqreturn_t mfgpt_tick(int irq, void *dev_id)
113117
/* Turn off the clock (and clear the event) */
114118
disable_timer(cs5535_event_clock);
115119

116-
if (cs5535_tick_mode == CLOCK_EVT_MODE_SHUTDOWN)
120+
if (clockevent_state_shutdown(&cs5535_clockevent))
117121
return IRQ_HANDLED;
118122

119123
/* Clear the counter */
120124
cs5535_mfgpt_write(cs5535_event_clock, MFGPT_REG_COUNTER, 0);
121125

122126
/* Restart the clock in periodic mode */
123127

124-
if (cs5535_tick_mode == CLOCK_EVT_MODE_PERIODIC)
128+
if (clockevent_state_periodic(&cs5535_clockevent))
125129
cs5535_mfgpt_write(cs5535_event_clock, MFGPT_REG_SETUP,
126130
MFGPT_SETUP_CNTEN | MFGPT_SETUP_CMP2);
127131

0 commit comments

Comments
 (0)