linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: hlwd: Pass irqchip when adding gpiochip
@ 2019-08-09 14:00 Linus Walleij
  2019-08-10 10:35 ` Jonathan Neuschäfer
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2019-08-09 14:00 UTC (permalink / raw)
  To: linux-gpio
  Cc: Bartosz Golaszewski, Linus Walleij, Jonathan Neuschäfer,
	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.

Cc: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Cc: Thierry Reding <treding@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpio/gpio-hlwd.c | 58 +++++++++++++++++++++-------------------
 1 file changed, 30 insertions(+), 28 deletions(-)

diff --git a/drivers/gpio/gpio-hlwd.c b/drivers/gpio/gpio-hlwd.c
index e5fa00f8145f..4a17599f6d44 100644
--- a/drivers/gpio/gpio-hlwd.c
+++ b/drivers/gpio/gpio-hlwd.c
@@ -244,43 +244,45 @@ static int hlwd_gpio_probe(struct platform_device *pdev)
 		ngpios = 32;
 	hlwd->gpioc.ngpio = ngpios;
 
-	res = devm_gpiochip_add_data(&pdev->dev, &hlwd->gpioc, hlwd);
-	if (res)
-		return res;
-
 	/* Mask and ack all interrupts */
 	iowrite32be(0, hlwd->regs + HW_GPIOB_INTMASK);
 	iowrite32be(0xffffffff, hlwd->regs + HW_GPIOB_INTFLAG);
 
 	/*
 	 * If this GPIO controller is not marked as an interrupt controller in
-	 * the DT, return.
+	 * the DT, skip interrupt support.
 	 */
-	if (!of_property_read_bool(pdev->dev.of_node, "interrupt-controller"))
-		return 0;
-
-	hlwd->irq = platform_get_irq(pdev, 0);
-	if (hlwd->irq < 0) {
-		dev_info(&pdev->dev, "platform_get_irq returned %d\n",
-			 hlwd->irq);
-		return hlwd->irq;
+	if (of_property_read_bool(pdev->dev.of_node, "interrupt-controller")) {
+		struct gpio_irq_chip *girq;
+
+		hlwd->irq = platform_get_irq(pdev, 0);
+		if (hlwd->irq < 0) {
+			dev_info(&pdev->dev, "platform_get_irq returned %d\n",
+				 hlwd->irq);
+			return hlwd->irq;
+		}
+
+		hlwd->irqc.name = dev_name(&pdev->dev);
+		hlwd->irqc.irq_mask = hlwd_gpio_irq_mask;
+		hlwd->irqc.irq_unmask = hlwd_gpio_irq_unmask;
+		hlwd->irqc.irq_enable = hlwd_gpio_irq_enable;
+		hlwd->irqc.irq_set_type = hlwd_gpio_irq_set_type;
+
+		girq = &hlwd->gpioc.irq;
+		girq->chip = &hlwd->irqc;
+		girq->parent_handler = hlwd_gpio_irqhandler;
+		girq->num_parents = 1;
+		girq->parents = devm_kcalloc(&pdev->dev, 1,
+					     sizeof(*girq->parents),
+					     GFP_KERNEL);
+		if (!girq->parents)
+			return -ENOMEM;
+		girq->parents[0] = hlwd->irq;
+		girq->default_type = IRQ_TYPE_NONE;
+		girq->handler = handle_level_irq;
 	}
 
-	hlwd->irqc.name = dev_name(&pdev->dev);
-	hlwd->irqc.irq_mask = hlwd_gpio_irq_mask;
-	hlwd->irqc.irq_unmask = hlwd_gpio_irq_unmask;
-	hlwd->irqc.irq_enable = hlwd_gpio_irq_enable;
-	hlwd->irqc.irq_set_type = hlwd_gpio_irq_set_type;
-
-	res = gpiochip_irqchip_add(&hlwd->gpioc, &hlwd->irqc, 0,
-				   handle_level_irq, IRQ_TYPE_NONE);
-	if (res)
-		return res;
-
-	gpiochip_set_chained_irqchip(&hlwd->gpioc, &hlwd->irqc,
-				     hlwd->irq, hlwd_gpio_irqhandler);
-
-	return 0;
+	return devm_gpiochip_add_data(&pdev->dev, &hlwd->gpioc, hlwd);
 }
 
 static const struct of_device_id hlwd_gpio_match[] = {
-- 
2.21.0


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

* Re: [PATCH] gpio: hlwd: Pass irqchip when adding gpiochip
  2019-08-09 14:00 [PATCH] gpio: hlwd: Pass irqchip when adding gpiochip Linus Walleij
@ 2019-08-10 10:35 ` Jonathan Neuschäfer
  2019-08-12 19:06   ` Jonathan Neuschäfer
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Neuschäfer @ 2019-08-10 10:35 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-gpio, Bartosz Golaszewski, Jonathan Neuschäfer,
	Thierry Reding

[-- Attachment #1: Type: text/plain, Size: 709 bytes --]

On Fri, Aug 09, 2019 at 04:00:05PM +0200, Linus Walleij wrote:
> 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.
> 
> Cc: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
> Cc: Thierry Reding <treding@nvidia.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---

Unfortunately, there seems to have been an unrelated regression between
5.0 and now affecting the Wii, so I can't easily test this patch right
now. But it looks good (esp. with git show -b).

Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] gpio: hlwd: Pass irqchip when adding gpiochip
  2019-08-10 10:35 ` Jonathan Neuschäfer
@ 2019-08-12 19:06   ` Jonathan Neuschäfer
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Neuschäfer @ 2019-08-12 19:06 UTC (permalink / raw)
  To: Jonathan Neuschäfer
  Cc: Linus Walleij, linux-gpio, Bartosz Golaszewski, Thierry Reding

[-- Attachment #1: Type: text/plain, Size: 904 bytes --]

On Sat, Aug 10, 2019 at 12:35:23PM +0200, Jonathan Neuschäfer wrote:
> On Fri, Aug 09, 2019 at 04:00:05PM +0200, Linus Walleij wrote:
> > 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.
> > 
> > Cc: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
> > Cc: Thierry Reding <treding@nvidia.com>
> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> > ---
> 
> Unfortunately, there seems to have been an unrelated regression between
> 5.0 and now affecting the Wii, so I can't easily test this patch right
> now. But it looks good (esp. with git show -b).
> 
> Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>

Ok, now I also tested it:

Tested-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2019-08-12 19:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-09 14:00 [PATCH] gpio: hlwd: Pass irqchip when adding gpiochip Linus Walleij
2019-08-10 10:35 ` Jonathan Neuschäfer
2019-08-12 19:06   ` Jonathan Neuschäfer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).