[PATCH v4 13/18] staging: mt7621-gpio: avoid to set up irqs if not defined in dts

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

 



If there is no interrupt defined in the dts 'irq_of_parse_and_map'
returns 0 and we should't set up interrupts for each gpio chip in
that case.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@xxxxxxxxx>
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 42 ++++++++++++++++---------------
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 1318003..96dee10 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -237,30 +237,32 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node *bank)
 		return ret;
 	}
 
-	/*
-	 * Manually request the irq here instead of passing a flow-handler
-	 * to gpiochip_set_chained_irqchip, because the irq is shared.
-	 */
-	ret = devm_request_irq(&pdev->dev, gpio->gpio_irq,
-			       mediatek_gpio_irq_handler, IRQF_SHARED,
-			       "mt7621", &rg->chip);
+	if (gpio->gpio_irq) {
+		/*
+		 * Manually request the irq here instead of passing a flow-handler
+		 * to gpiochip_set_chained_irqchip, because the irq is shared.
+		 */
+		ret = devm_request_irq(&pdev->dev, gpio->gpio_irq,
+				       mediatek_gpio_irq_handler, IRQF_SHARED,
+				       "mt7621", &rg->chip);
+
+		if (ret) {
+			dev_err(&pdev->dev, "Error requesting IRQ %d: %d\n",
+				gpio->gpio_irq, ret);
+			return ret;
+		}
 
-	if (ret) {
-		dev_err(&pdev->dev, "Error requesting IRQ %d: %d\n",
-			gpio->gpio_irq, ret);
-		return ret;
-	}
+		ret = gpiochip_irqchip_add(&rg->chip, &mediatek_gpio_irq_chip,
+					   0, handle_simple_irq, IRQ_TYPE_NONE);
+		if (ret) {
+			dev_err(&pdev->dev, "failed to add gpiochip_irqchip\n");
+			return ret;
+		}
 
-	ret = gpiochip_irqchip_add(&rg->chip, &mediatek_gpio_irq_chip,
-				   0, handle_simple_irq, IRQ_TYPE_NONE);
-	if (ret) {
-		dev_err(&pdev->dev, "failed to add gpiochip_irqchip\n");
-		return ret;
+		gpiochip_set_chained_irqchip(&rg->chip, &mediatek_gpio_irq_chip,
+					     gpio->gpio_irq, NULL);
 	}
 
-	gpiochip_set_chained_irqchip(&rg->chip, &mediatek_gpio_irq_chip,
-				     gpio->gpio_irq, NULL);
-
 	/* set polarity to low for all gpios */
 	mtk_gpio_w32(rg, GPIO_REG_POL, 0);
 
-- 
2.7.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux