Linux-GPIO Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] gpio: mt7621: Pass irqchip when adding gpiochip
@ 2019-08-09 14:11 Linus Walleij
  2019-08-23  6:56 ` René van Dorst
  0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2019-08-09 14:11 UTC (permalink / raw)
  To: linux-gpio
  Cc: Bartosz Golaszewski, Linus Walleij, René van Dorst,
	Greg Ungerer, Nicholas Mc Guire, Sergio Paracuellos,
	Thierry Reding

We need to convert all old gpio irqchips to pass the irqchip
setup along when adding the gpio_chip. For more info see
drivers/gpio/TODO.

For chained irqchips this is a pretty straight-forward
conversion.

This driver requests the IRQ directly in the driver so it
differs a bit from the others.

Cc: René van Dorst <opensource@vdorst.com>
Cc: Greg Ungerer <gerg@kernel.org>
Cc: Nicholas Mc Guire <hofrat@osadl.org>
Cc: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Cc: Thierry Reding <treding@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpio/gpio-mt7621.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/gpio/gpio-mt7621.c b/drivers/gpio/gpio-mt7621.c
index 79654fb2e50f..d1d785f983a7 100644
--- a/drivers/gpio/gpio-mt7621.c
+++ b/drivers/gpio/gpio-mt7621.c
@@ -241,13 +241,6 @@ mediatek_gpio_bank_probe(struct device *dev,
 	if (!rg->chip.label)
 		return -ENOMEM;
 
-	ret = devm_gpiochip_add_data(dev, &rg->chip, mtk);
-	if (ret < 0) {
-		dev_err(dev, "Could not register gpio %d, ret=%d\n",
-			rg->chip.ngpio, ret);
-		return ret;
-	}
-
 	rg->irq_chip.name = dev_name(dev);
 	rg->irq_chip.parent_device = dev;
 	rg->irq_chip.irq_unmask = mediatek_gpio_irq_unmask;
@@ -256,8 +249,10 @@ mediatek_gpio_bank_probe(struct device *dev,
 	rg->irq_chip.irq_set_type = mediatek_gpio_irq_type;
 
 	if (mtk->gpio_irq) {
+		struct gpio_irq_chip *girq;
+
 		/*
-		 * Manually request the irq here instead of passing
+		 * Directly request the irq here instead of passing
 		 * a flow-handler to gpiochip_set_chained_irqchip,
 		 * because the irq is shared.
 		 */
@@ -271,15 +266,21 @@ mediatek_gpio_bank_probe(struct device *dev,
 			return ret;
 		}
 
-		ret = gpiochip_irqchip_add(&rg->chip, &rg->irq_chip,
-					   0, handle_simple_irq, IRQ_TYPE_NONE);
-		if (ret) {
-			dev_err(dev, "failed to add gpiochip_irqchip\n");
-			return ret;
-		}
+		girq = &rg->chip.irq;
+		girq->chip = &rg->irq_chip;
+		/* This will let us handle the parent IRQ in the driver */
+		girq->parent_handler = NULL;
+		girq->num_parents = 0;
+		girq->parents = NULL;
+		girq->default_type = IRQ_TYPE_NONE;
+		girq->handler = handle_simple_irq;
+	}
 
-		gpiochip_set_chained_irqchip(&rg->chip, &rg->irq_chip,
-					     mtk->gpio_irq, NULL);
+	ret = devm_gpiochip_add_data(dev, &rg->chip, mtk);
+	if (ret < 0) {
+		dev_err(dev, "Could not register gpio %d, ret=%d\n",
+			rg->chip.ngpio, ret);
+		return ret;
 	}
 
 	/* set polarity to low for all gpios */
-- 
2.21.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] gpio: mt7621: Pass irqchip when adding gpiochip
  2019-08-09 14:11 [PATCH] gpio: mt7621: Pass irqchip when adding gpiochip Linus Walleij
@ 2019-08-23  6:56 ` René van Dorst
  0 siblings, 0 replies; 2+ messages in thread
From: René van Dorst @ 2019-08-23  6:56 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-gpio, Bartosz Golaszewski, Greg Ungerer, Nicholas Mc Guire,
	Sergio Paracuellos, Thierry Reding

Hi Linus,

Sorry for the late reply.

Quoting Linus Walleij <linus.walleij@linaro.org>:

> We need to convert all old gpio irqchips to pass the irqchip
> setup along when adding the gpio_chip. For more info see
> drivers/gpio/TODO.
>
> For chained irqchips this is a pretty straight-forward
> conversion.
>
> This driver requests the IRQ directly in the driver so it
> differs a bit from the others.
>
> Cc: René van Dorst <opensource@vdorst.com>
> Cc: Greg Ungerer <gerg@kernel.org>
> Cc: Nicholas Mc Guire <hofrat@osadl.org>
> Cc: Sergio Paracuellos <sergio.paracuellos@gmail.com>
> Cc: Thierry Reding <treding@nvidia.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/gpio/gpio-mt7621.c | 33 +++++++++++++++++----------------
>  1 file changed, 17 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/gpio/gpio-mt7621.c b/drivers/gpio/gpio-mt7621.c
> index 79654fb2e50f..d1d785f983a7 100644
> --- a/drivers/gpio/gpio-mt7621.c
> +++ b/drivers/gpio/gpio-mt7621.c
> @@ -241,13 +241,6 @@ mediatek_gpio_bank_probe(struct device *dev,
>  	if (!rg->chip.label)
>  		return -ENOMEM;
>
> -	ret = devm_gpiochip_add_data(dev, &rg->chip, mtk);
> -	if (ret < 0) {
> -		dev_err(dev, "Could not register gpio %d, ret=%d\n",
> -			rg->chip.ngpio, ret);
> -		return ret;
> -	}
> -
>  	rg->irq_chip.name = dev_name(dev);
>  	rg->irq_chip.parent_device = dev;
>  	rg->irq_chip.irq_unmask = mediatek_gpio_irq_unmask;
> @@ -256,8 +249,10 @@ mediatek_gpio_bank_probe(struct device *dev,
>  	rg->irq_chip.irq_set_type = mediatek_gpio_irq_type;
>
>  	if (mtk->gpio_irq) {
> +		struct gpio_irq_chip *girq;
> +
>  		/*
> -		 * Manually request the irq here instead of passing
> +		 * Directly request the irq here instead of passing
>  		 * a flow-handler to gpiochip_set_chained_irqchip,
>  		 * because the irq is shared.
>  		 */
> @@ -271,15 +266,21 @@ mediatek_gpio_bank_probe(struct device *dev,
>  			return ret;
>  		}
>
> -		ret = gpiochip_irqchip_add(&rg->chip, &rg->irq_chip,
> -					   0, handle_simple_irq, IRQ_TYPE_NONE);
> -		if (ret) {
> -			dev_err(dev, "failed to add gpiochip_irqchip\n");
> -			return ret;
> -		}
> +		girq = &rg->chip.irq;
> +		girq->chip = &rg->irq_chip;
> +		/* This will let us handle the parent IRQ in the driver */
> +		girq->parent_handler = NULL;
> +		girq->num_parents = 0;
> +		girq->parents = NULL;
> +		girq->default_type = IRQ_TYPE_NONE;
> +		girq->handler = handle_simple_irq;
> +	}
>
> -		gpiochip_set_chained_irqchip(&rg->chip, &rg->irq_chip,
> -					     mtk->gpio_irq, NULL);
> +	ret = devm_gpiochip_add_data(dev, &rg->chip, mtk);
> +	if (ret < 0) {
> +		dev_err(dev, "Could not register gpio %d, ret=%d\n",
> +			rg->chip.ngpio, ret);
> +		return ret;
>  	}
>
>  	/* set polarity to low for all gpios */
> --
> 2.21.0

I have this patch applied for a while.
I didn't encounter an issues.

Tested-by: René van Dorst <opensource@vdorst.com>

Greats,

René







^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-09 14:11 [PATCH] gpio: mt7621: Pass irqchip when adding gpiochip Linus Walleij
2019-08-23  6:56 ` René van Dorst

Linux-GPIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-gpio/0 linux-gpio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-gpio linux-gpio/ https://lore.kernel.org/linux-gpio \
		linux-gpio@vger.kernel.org linux-gpio@archiver.kernel.org
	public-inbox-index linux-gpio


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-gpio


AGPL code for this site: git clone https://public-inbox.org/ public-inbox