Skip to contentSkip to conversation

rtc-ds1553: Drop IRQF_DISABLED

PATCH NAK Atsushi Nemoto 2 participants 3 messages Apr 6, 2009 – Apr 7, 2009 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc-ds1553: Drop IRQF_DISABLED

IRQF_DISABLED should be be used with IRQF_SHARED. Drop IRQF_DISABLED and add spin_lock_irqsave/spin_unlock_irqrestore to the interrupt handler.

---
 drivers/rtc/rtc-ds1553.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
drivers/rtc/rtc-ds1553.c +7 -2
index 38d472b..395f01b 100644
@@ -195,14 +195,19 @@ static irqreturn_t ds1553_rtc_interrupt(int irq, void *dev_id)
 	struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
 	void __iomem *ioaddr = pdata->ioaddr;
 	unsigned long events = RTC_IRQF;
+	unsigned long flags;
 
+	spin_lock_irqsave(&pdata->rtc->irq_lock, flags);
 	/* read and clear interrupt */
-	if (!(readb(ioaddr + RTC_FLAGS) & RTC_FLAGS_AF))
+	if (!(readb(ioaddr + RTC_FLAGS) & RTC_FLAGS_AF)) {
+		spin_unlock_irqrestore(&pdata->rtc->irq_lock, flags);
 		return IRQ_NONE;
+	}
 	if (readb(ioaddr + RTC_SECONDS_ALARM) & 0x80)
 		events |= RTC_UF;
 	else
 		events |= RTC_AF;
+	spin_unlock_irqrestore(&pdata->rtc->irq_lock, flags);
 	rtc_update_irq(pdata->rtc, 1, events);
 	return IRQ_HANDLED;
 }
@@ -329,7 +334,7 @@ static int __devinit ds1553_rtc_probe(struct platform_device *pdev)
 	if (pdata->irq > 0) {
 		writeb(0, ioaddr + RTC_INTERRUPTS);
 		if (request_irq(pdata->irq, ds1553_rtc_interrupt,
-				IRQF_DISABLED | IRQF_SHARED,
+				IRQF_SHARED,
 				pdev->name, pdev) < 0) {
 			dev_warn(&pdev->dev, "interrupt not available.\n");
 			pdata->irq = 0;
Signature · 1 line
1.5.6.3
#1 lore raw
Quoted 3 lines · Atsushi Nemoto

IRQF_DISABLED should be be used with IRQF_SHARED. Drop IRQF_DISABLED and add spin_lock_irqsave/spin_unlock_irqrestore to the interrupt handler.

I think you should use IRQF_DISABLED if at all possible. Only broken hardware has an excuse not to.

NAK

Quoted 39 lines
---
 drivers/rtc/rtc-ds1553.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
drivers/rtc/rtc-ds1553.c +7 -2
index 38d472b..395f01b 100644
@@ -195,14 +195,19 @@ static irqreturn_t ds1553_rtc_interrupt(int irq, void *dev_id)
 	struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
 	void __iomem *ioaddr = pdata->ioaddr;
 	unsigned long events = RTC_IRQF;
+	unsigned long flags;
 
+	spin_lock_irqsave(&pdata->rtc->irq_lock, flags);
 	/* read and clear interrupt */
-	if (!(readb(ioaddr + RTC_FLAGS) & RTC_FLAGS_AF))
+	if (!(readb(ioaddr + RTC_FLAGS) & RTC_FLAGS_AF)) {
+		spin_unlock_irqrestore(&pdata->rtc->irq_lock, flags);
 		return IRQ_NONE;
+	}
 	if (readb(ioaddr + RTC_SECONDS_ALARM) & 0x80)
 		events |= RTC_UF;
 	else
 		events |= RTC_AF;
+	spin_unlock_irqrestore(&pdata->rtc->irq_lock, flags);
 	rtc_update_irq(pdata->rtc, 1, events);
 	return IRQ_HANDLED;
 }
@@ -329,7 +334,7 @@ static int __devinit ds1553_rtc_probe(struct platform_device *pdev)
 	if (pdata->irq > 0) {
 		writeb(0, ioaddr + RTC_INTERRUPTS);
 		if (request_irq(pdata->irq, ds1553_rtc_interrupt,
-				IRQF_DISABLED | IRQF_SHARED,
+				IRQF_SHARED,
 				pdev->name, pdev) < 0) {
 			dev_warn(&pdev->dev, "interrupt not available.\n");
 			pdata->irq = 0;
#2 lore raw
Quoted 8 lines · Peter Zijlstra
Quoted 3 lines

IRQF_DISABLED should be be used with IRQF_SHARED. Drop IRQF_DISABLED and add spin_lock_irqsave/spin_unlock_irqrestore to the interrupt handler.

I think you should use IRQF_DISABLED if at all possible. Only broken hardware has an excuse not to.

NAK

OK, then I will drop IRQF_SHARED instead. There is no in-tree user of this driver and only out-of-tree user I know uses dedicated irq line for this RTC.

---
Atsushi Nemoto