diff mbox

[6/9] bfin: delay IRQ registration until driver is ready

Message ID 20090620160908.6953.15683.stgit@i1501.lan.towertech.it
State Accepted, archived
Headers show

Commit Message

Alessandro Zummo June 20, 2009, 4:09 p.m. UTC
From: Mike Frysinger <vapier@gentoo.org>

Make sure we do not actually request the RTC IRQ until the device driver is
fully ready to handle and process any interrupt.  This way a spurious
interrupt won't crash the system (which may happen if the bootloader was
poking the RTC right before booting Linux).

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
---

 drivers/rtc/rtc-bfin.c |   27 +++++++++++++--------------
 1 files changed, 13 insertions(+), 14 deletions(-)



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
-~----------~----~----~----~------~----~------~--~---

Comments

Andrew Morton June 26, 2009, 11:02 p.m. UTC | #1
On Sat, 20 Jun 2009 18:09:08 +0200
Alessandro Zummo <a.zummo@towertech.it> wrote:

> Make sure we do not actually request the RTC IRQ until the device driver is
> fully ready to handle and process any interrupt.  This way a spurious
> interrupt won't crash the system (which may happen if the bootloader was
> poking the RTC right before booting Linux).

This one looks like 2.6.31 material?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
-~----------~----~----~----~------~----~------~--~---
Alessandro Zummo June 27, 2009, 11:44 a.m. UTC | #2
On Fri, 26 Jun 2009 16:02:26 -0700
Andrew Morton <akpm@linux-foundation.org> wrote:

> > Make sure we do not actually request the RTC IRQ until the device driver is
> > fully ready to handle and process any interrupt.  This way a spurious
> > interrupt won't crash the system (which may happen if the bootloader was
> > poking the RTC right before booting Linux).  
> 
> This one looks like 2.6.31 material?

 Yes, I'd say it's appropriate for 2.6.31
diff mbox

Patch

diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c
index abad9f6..697a22b 100644
--- a/drivers/rtc/rtc-bfin.c
+++ b/drivers/rtc/rtc-bfin.c
@@ -1,8 +1,8 @@ 
 /*
  * Blackfin On-Chip Real Time Clock Driver
- *  Supports BF52[257]/BF53[123]/BF53[467]/BF54[24789]
+ *  Supports BF51x/BF52x/BF53[123]/BF53[467]/BF54x
  *
- * Copyright 2004-2008 Analog Devices Inc.
+ * Copyright 2004-2009 Analog Devices Inc.
  *
  * Enter bugs at http://blackfin.uclinux.org/
  *
@@ -363,7 +363,7 @@  static int __devinit bfin_rtc_probe(struct platform_device *pdev)
 	struct bfin_rtc *rtc;
 	struct device *dev = &pdev->dev;
 	int ret = 0;
-	unsigned long timeout;
+	unsigned long timeout = jiffies + HZ;
 
 	dev_dbg_stamp(dev);
 
@@ -374,31 +374,30 @@  static int __devinit bfin_rtc_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, rtc);
 	device_init_wakeup(dev, 1);
 
+	/* Register our RTC with the RTC framework */
+	rtc->rtc_dev = rtc_device_register(pdev->name, dev, &bfin_rtc_ops, THIS_MODULE);
+	if (unlikely(IS_ERR(rtc->rtc_dev))) {
+		ret = PTR_ERR(rtc->rtc_dev);
+		goto err;
+	}
+
 	/* Grab the IRQ and init the hardware */
 	ret = request_irq(IRQ_RTC, bfin_rtc_interrupt, 0, pdev->name, dev);
 	if (unlikely(ret))
-		goto err;
+		goto err_reg;
 	/* sometimes the bootloader touched things, but the write complete was not
 	 * enabled, so let's just do a quick timeout here since the IRQ will not fire ...
 	 */
-	timeout = jiffies + HZ;
 	while (bfin_read_RTC_ISTAT() & RTC_ISTAT_WRITE_PENDING)
 		if (time_after(jiffies, timeout))
 			break;
 	bfin_rtc_reset(dev, RTC_ISTAT_WRITE_COMPLETE);
 	bfin_write_RTC_SWCNT(0);
 
-	/* Register our RTC with the RTC framework */
-	rtc->rtc_dev = rtc_device_register(pdev->name, dev, &bfin_rtc_ops, THIS_MODULE);
-	if (unlikely(IS_ERR(rtc->rtc_dev))) {
-		ret = PTR_ERR(rtc->rtc_dev);
-		goto err_irq;
-	}
-
 	return 0;
 
- err_irq:
-	free_irq(IRQ_RTC, dev);
+ err_reg:
+	rtc_device_unregister(rtc->rtc_dev);
  err:
 	kfree(rtc);
 	return ret;