[PATCH] cs5535-clockevt: set up the MFGPT only after registering the IRQ

From: Nick Alcock
Date: Tue Feb 02 2016 - 09:57:56 EST


This prevents a race whereby the IRQ arrives before the clockevent
handler is installed.

Signed-off-by: Nick Alcock <nick.alcock@xxxxxxxxxx>
Inspired-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
---
drivers/clocksource/cs5535-clockevt.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/clocksource/cs5535-clockevt.c b/drivers/clocksource/cs5535-clockevt.c
index 9a7e37c..5737e17 100644
--- a/drivers/clocksource/cs5535-clockevt.c
+++ b/drivers/clocksource/cs5535-clockevt.c
@@ -152,6 +152,18 @@ static int __init cs5535_mfgpt_init(void)
}
cs5535_event_clock = timer;

+ /* Set the clock scale and enable the event mode for CMP2 */
+ val = MFGPT_SCALE | (3 << 8);
+
+ cs5535_mfgpt_write(cs5535_event_clock, MFGPT_REG_SETUP, val);
+
+ /* Set up the clock event */
+ printk(KERN_INFO DRV_NAME
+ ": Registering MFGPT timer as a clock event, using IRQ %d\n",
+ timer_irq);
+ clockevents_config_and_register(&cs5535_clockevent, MFGPT_HZ,
+ 0xF, 0xFFFE);
+
/* Set up the IRQ on the MFGPT side */
if (cs5535_mfgpt_setup_irq(timer, MFGPT_CMP2, &timer_irq)) {
printk(KERN_ERR DRV_NAME ": Could not set up IRQ %d\n",
@@ -166,18 +178,6 @@ static int __init cs5535_mfgpt_init(void)
goto err_irq;
}

- /* Set the clock scale and enable the event mode for CMP2 */
- val = MFGPT_SCALE | (3 << 8);
-
- cs5535_mfgpt_write(cs5535_event_clock, MFGPT_REG_SETUP, val);
-
- /* Set up the clock event */
- printk(KERN_INFO DRV_NAME
- ": Registering MFGPT timer as a clock event, using IRQ %d\n",
- timer_irq);
- clockevents_config_and_register(&cs5535_clockevent, MFGPT_HZ,
- 0xF, 0xFFFE);
-
return 0;

err_irq:
--
2.7.0.198.g6dd47b6