Skip to content

Commit

Permalink
rtc-at32ap700x: fix irq init oops
Browse files Browse the repository at this point in the history
Reorder at32_rtc_probe() so that it's safe (no oopsing) to fire the
IRQ handler the instant that it's registered.  (Bug noted via "Debug
shared IRQ handlers" kernel debug option.)

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: <hcegtvedt@atmel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
David Brownell authored and Linus Torvalds committed Dec 18, 2007
1 parent fe4304b commit 8d431db
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions drivers/rtc/rtc-at32ap700x.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,18 +225,12 @@ static int __init at32_rtc_probe(struct platform_device *pdev)
goto out;
}

ret = request_irq(irq, at32_rtc_interrupt, IRQF_SHARED, "rtc", rtc);
if (ret) {
dev_dbg(&pdev->dev, "could not request irq %d\n", irq);
goto out;
}

rtc->irq = irq;
rtc->regs = ioremap(regs->start, regs->end - regs->start + 1);
if (!rtc->regs) {
ret = -ENOMEM;
dev_dbg(&pdev->dev, "could not map I/O memory\n");
goto out_free_irq;
goto out;
}
spin_lock_init(&rtc->lock);

Expand All @@ -253,12 +247,18 @@ static int __init at32_rtc_probe(struct platform_device *pdev)
| RTC_BIT(CTRL_EN));
}

ret = request_irq(irq, at32_rtc_interrupt, IRQF_SHARED, "rtc", rtc);
if (ret) {
dev_dbg(&pdev->dev, "could not request irq %d\n", irq);
goto out_iounmap;
}

rtc->rtc = rtc_device_register(pdev->name, &pdev->dev,
&at32_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc->rtc)) {
dev_dbg(&pdev->dev, "could not register rtc device\n");
ret = PTR_ERR(rtc->rtc);
goto out_iounmap;
goto out_free_irq;
}

platform_set_drvdata(pdev, rtc);
Expand All @@ -268,10 +268,10 @@ static int __init at32_rtc_probe(struct platform_device *pdev)

return 0;

out_iounmap:
iounmap(rtc->regs);
out_free_irq:
free_irq(irq, rtc);
out_iounmap:
iounmap(rtc->regs);
out:
kfree(rtc);
return ret;
Expand Down

0 comments on commit 8d431db

Please sign in to comment.