1 From 94d8be554c4ea0a28486be59e2eaae937c4403bb Mon Sep 17 00:00:00 2001
2 From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
3 Date: Thu, 17 Mar 2016 21:09:43 +0100
4 Subject: [PATCH 324/366] clockevents/drivers/timer-atmel-pit: fix double
7 clockevents_exchange_device() changes the state from detached to shutdown
8 and so at that point the IRQ has not yet been requested.
10 Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
11 Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
12 Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
14 drivers/clocksource/timer-atmel-pit.c | 8 +++++++-
15 1 file changed, 7 insertions(+), 1 deletion(-)
17 diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
18 index a7abdb6..7a40f7e 100644
19 --- a/drivers/clocksource/timer-atmel-pit.c
20 +++ b/drivers/clocksource/timer-atmel-pit.c
21 @@ -46,6 +46,7 @@ struct pit_data {
29 @@ -96,7 +97,10 @@ static int pit_clkevt_shutdown(struct clock_event_device *dev)
31 /* disable irq, leaving the clocksource active */
32 pit_write(data->base, AT91_PIT_MR, (data->cycle - 1) | AT91_PIT_PITEN);
33 - free_irq(data->irq, data);
34 + if (data->irq_requested) {
35 + free_irq(data->irq, data);
36 + data->irq_requested = false;
41 @@ -115,6 +119,8 @@ static int pit_clkevt_set_periodic(struct clock_event_device *dev)
43 panic(pr_fmt("Unable to setup IRQ\n"));
45 + data->irq_requested = true;
47 /* update clocksource counter */
48 data->cnt += data->cycle * PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR));
49 pit_write(data->base, AT91_PIT_MR,