[PATCH 21/21] at91sam9_wdt: use devm_irq_of_parse_and_map()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




From: Nikita Yushchenko <nyushchenko@xxxxxxxxxxxxx>

This avoids leak of IRQ mapping on error paths, and makes it possible
to use devm_request_irq() without facing unmap-while-handler-installed
issues.

Signed-off-by: Nikita Yushchenko <nyushchenko@xxxxxxxxxxxxx>
---
 drivers/watchdog/at91sam9_wdt.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
index 489729b..11ebe54 100644
--- a/drivers/watchdog/at91sam9_wdt.c
+++ b/drivers/watchdog/at91sam9_wdt.c
@@ -207,9 +207,9 @@ static int at91_wdt_init(struct platform_device *pdev, struct at91wdt *wdt)
 			 "min heartbeat and max heartbeat might be too close for the system to handle it correctly\n");
 
 	if ((tmp & AT91_WDT_WDFIEN) && wdt->irq) {
-		err = request_irq(wdt->irq, wdt_interrupt,
-				  IRQF_SHARED | IRQF_IRQPOLL,
-				  pdev->name, wdt);
+		err = devm_request_irq(dev, wdt->irq, wdt_interrupt,
+				       IRQF_SHARED | IRQF_IRQPOLL,
+				       pdev->name, wdt);
 		if (err)
 			return err;
 	}
@@ -270,9 +270,11 @@ static int of_at91wdt_init(struct device_node *np, struct at91wdt *wdt)
 	const char *tmp;
 
 	/* Get the interrupts property */
-	wdt->irq = irq_of_parse_and_map(np, 0);
-	if (!wdt->irq)
+	wdt->irq = devm_irq_of_parse_and_map(wdt->wdd.parent, np, 0);
+	if (wdt->irq <= 0) {
 		dev_warn(wdt->wdd.parent, "failed to get IRQ from DT\n");
+		wdt->irq = NO_IRQ;
+	}
 
 	if (!of_property_read_u32_index(np, "atmel,max-heartbeat-sec", 0,
 					&max)) {
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux