Skip to content

Commit d7f430d

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/egtvedt/linux-avr32
Pull AVR32 update from Hans-Christian Egtvedt. * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/egtvedt/linux-avr32: AVR32/time: Migrate to new 'set-state' interface
2 parents 52721d9 + 09adcdf commit d7f430d

File tree

1 file changed

+33
-32
lines changed

1 file changed

+33
-32
lines changed

arch/avr32/kernel/time.c

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <mach/pm.h>
2020

21+
static bool disable_cpu_idle_poll;
2122

2223
static cycle_t read_cycle_count(struct clocksource *cs)
2324
{
@@ -80,45 +81,45 @@ static int comparator_next_event(unsigned long delta,
8081
return 0;
8182
}
8283

83-
static void comparator_mode(enum clock_event_mode mode,
84-
struct clock_event_device *evdev)
84+
static int comparator_shutdown(struct clock_event_device *evdev)
8585
{
86-
switch (mode) {
87-
case CLOCK_EVT_MODE_ONESHOT:
88-
pr_debug("%s: start\n", evdev->name);
89-
/* FALLTHROUGH */
90-
case CLOCK_EVT_MODE_RESUME:
86+
pr_debug("%s: %s\n", __func__, evdev->name);
87+
sysreg_write(COMPARE, 0);
88+
89+
if (disable_cpu_idle_poll) {
90+
disable_cpu_idle_poll = false;
9191
/*
92-
* If we're using the COUNT and COMPARE registers we
93-
* need to force idle poll.
92+
* Only disable idle poll if we have forced that
93+
* in a previous call.
9494
*/
95-
cpu_idle_poll_ctrl(true);
96-
break;
97-
case CLOCK_EVT_MODE_UNUSED:
98-
case CLOCK_EVT_MODE_SHUTDOWN:
99-
sysreg_write(COMPARE, 0);
100-
pr_debug("%s: stop\n", evdev->name);
101-
if (evdev->mode == CLOCK_EVT_MODE_ONESHOT ||
102-
evdev->mode == CLOCK_EVT_MODE_RESUME) {
103-
/*
104-
* Only disable idle poll if we have forced that
105-
* in a previous call.
106-
*/
107-
cpu_idle_poll_ctrl(false);
108-
}
109-
break;
110-
default:
111-
BUG();
95+
cpu_idle_poll_ctrl(false);
11296
}
97+
return 0;
98+
}
99+
100+
static int comparator_set_oneshot(struct clock_event_device *evdev)
101+
{
102+
pr_debug("%s: %s\n", __func__, evdev->name);
103+
104+
disable_cpu_idle_poll = true;
105+
/*
106+
* If we're using the COUNT and COMPARE registers we
107+
* need to force idle poll.
108+
*/
109+
cpu_idle_poll_ctrl(true);
110+
111+
return 0;
113112
}
114113

115114
static struct clock_event_device comparator = {
116-
.name = "avr32_comparator",
117-
.features = CLOCK_EVT_FEAT_ONESHOT,
118-
.shift = 16,
119-
.rating = 50,
120-
.set_next_event = comparator_next_event,
121-
.set_mode = comparator_mode,
115+
.name = "avr32_comparator",
116+
.features = CLOCK_EVT_FEAT_ONESHOT,
117+
.shift = 16,
118+
.rating = 50,
119+
.set_next_event = comparator_next_event,
120+
.set_state_shutdown = comparator_shutdown,
121+
.set_state_oneshot = comparator_set_oneshot,
122+
.tick_resume = comparator_set_oneshot,
122123
};
123124

124125
void read_persistent_clock(struct timespec *ts)

0 commit comments

Comments
 (0)