Linux-GPIO Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] gpio: wcove: Use irqchip template
@ 2020-07-17 15:19 Linus Walleij
  2020-07-22  8:57 ` Hans de Goede
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2020-07-17 15:19 UTC (permalink / raw)
  To: linux-gpio
  Cc: Bartosz Golaszewski, Linus Walleij, Bin Gao, Andy Shevchenko,
	Hans de Goede

This makes the driver use the irqchip template to assign
properties to the gpio_irq_chip instead of using the
explicit calls to gpiochip_irqchip_add_nested() and
gpiochip_set_nested_irqchip(). The irqchip is instead
added while adding the gpiochip.

Cc: Bin Gao <bin.gao@linux.intel.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Same notices as on the Crystalcove: this one I actually
managed to compiletest properly.
---
 drivers/gpio/gpio-wcove.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c
index 8b481b3c1ebe..135645096575 100644
--- a/drivers/gpio/gpio-wcove.c
+++ b/drivers/gpio/gpio-wcove.c
@@ -400,6 +400,7 @@ static int wcove_gpio_probe(struct platform_device *pdev)
 	struct wcove_gpio *wg;
 	int virq, ret, irq;
 	struct device *dev;
+	struct gpio_irq_chip *girq;
 
 	/*
 	 * This gpio platform device is created by a mfd device (see
@@ -442,19 +443,6 @@ static int wcove_gpio_probe(struct platform_device *pdev)
 	wg->dev = dev;
 	wg->regmap = pmic->regmap;
 
-	ret = devm_gpiochip_add_data(dev, &wg->chip, wg);
-	if (ret) {
-		dev_err(dev, "Failed to add gpiochip: %d\n", ret);
-		return ret;
-	}
-
-	ret = gpiochip_irqchip_add_nested(&wg->chip, &wcove_irqchip, 0,
-					  handle_simple_irq, IRQ_TYPE_NONE);
-	if (ret) {
-		dev_err(dev, "Failed to add irqchip: %d\n", ret);
-		return ret;
-	}
-
 	virq = regmap_irq_get_virq(wg->regmap_irq_chip, irq);
 	if (virq < 0) {
 		dev_err(dev, "Failed to get virq by irq %d\n", irq);
@@ -468,7 +456,21 @@ static int wcove_gpio_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	gpiochip_set_nested_irqchip(&wg->chip, &wcove_irqchip, virq);
+	girq = &wg->chip.irq;
+	girq->chip = &wcove_irqchip;
+	/* 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;
+	girq->threaded = true;
+
+	ret = devm_gpiochip_add_data(dev, &wg->chip, wg);
+	if (ret) {
+		dev_err(dev, "Failed to add gpiochip: %d\n", ret);
+		return ret;
+	}
 
 	/* Enable GPIO0 interrupts */
 	ret = regmap_update_bits(wg->regmap, IRQ_MASK_BASE, GPIO_IRQ0_MASK,
-- 
2.26.2


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

* Re: [PATCH] gpio: wcove: Use irqchip template
  2020-07-17 15:19 [PATCH] gpio: wcove: Use irqchip template Linus Walleij
@ 2020-07-22  8:57 ` Hans de Goede
  2020-07-22 10:58   ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Hans de Goede @ 2020-07-22  8:57 UTC (permalink / raw)
  To: Linus Walleij, linux-gpio; +Cc: Bartosz Golaszewski, Bin Gao, Andy Shevchenko

Hi,

On 7/17/20 5:19 PM, Linus Walleij wrote:
> This makes the driver use the irqchip template to assign
> properties to the gpio_irq_chip instead of using the
> explicit calls to gpiochip_irqchip_add_nested() and
> gpiochip_set_nested_irqchip(). The irqchip is instead
> added while adding the gpiochip.
> 
> Cc: Bin Gao <bin.gao@linux.intel.com>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> Same notices as on the Crystalcove: this one I actually
> managed to compiletest properly.

I've given this patch a test-run on a machine with the
Whiskey Cove PMIC and with the caveat that I've not
actually tested the GPIO IRQ functionality, since that
does not seem to be used on any machines, I see no adverse
side effects from this patch, so it is:

Tested-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans




> ---
>   drivers/gpio/gpio-wcove.c | 30 ++++++++++++++++--------------
>   1 file changed, 16 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c
> index 8b481b3c1ebe..135645096575 100644
> --- a/drivers/gpio/gpio-wcove.c
> +++ b/drivers/gpio/gpio-wcove.c
> @@ -400,6 +400,7 @@ static int wcove_gpio_probe(struct platform_device *pdev)
>   	struct wcove_gpio *wg;
>   	int virq, ret, irq;
>   	struct device *dev;
> +	struct gpio_irq_chip *girq;
>   
>   	/*
>   	 * This gpio platform device is created by a mfd device (see
> @@ -442,19 +443,6 @@ static int wcove_gpio_probe(struct platform_device *pdev)
>   	wg->dev = dev;
>   	wg->regmap = pmic->regmap;
>   
> -	ret = devm_gpiochip_add_data(dev, &wg->chip, wg);
> -	if (ret) {
> -		dev_err(dev, "Failed to add gpiochip: %d\n", ret);
> -		return ret;
> -	}
> -
> -	ret = gpiochip_irqchip_add_nested(&wg->chip, &wcove_irqchip, 0,
> -					  handle_simple_irq, IRQ_TYPE_NONE);
> -	if (ret) {
> -		dev_err(dev, "Failed to add irqchip: %d\n", ret);
> -		return ret;
> -	}
> -
>   	virq = regmap_irq_get_virq(wg->regmap_irq_chip, irq);
>   	if (virq < 0) {
>   		dev_err(dev, "Failed to get virq by irq %d\n", irq);
> @@ -468,7 +456,21 @@ static int wcove_gpio_probe(struct platform_device *pdev)
>   		return ret;
>   	}
>   
> -	gpiochip_set_nested_irqchip(&wg->chip, &wcove_irqchip, virq);
> +	girq = &wg->chip.irq;
> +	girq->chip = &wcove_irqchip;
> +	/* 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;
> +	girq->threaded = true;
> +
> +	ret = devm_gpiochip_add_data(dev, &wg->chip, wg);
> +	if (ret) {
> +		dev_err(dev, "Failed to add gpiochip: %d\n", ret);
> +		return ret;
> +	}
>   
>   	/* Enable GPIO0 interrupts */
>   	ret = regmap_update_bits(wg->regmap, IRQ_MASK_BASE, GPIO_IRQ0_MASK,
> 


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

* Re: [PATCH] gpio: wcove: Use irqchip template
  2020-07-22  8:57 ` Hans de Goede
@ 2020-07-22 10:58   ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2020-07-22 10:58 UTC (permalink / raw)
  To: Hans de Goede; +Cc: Linus Walleij, linux-gpio, Bartosz Golaszewski, Bin Gao

On Wed, Jul 22, 2020 at 10:57:08AM +0200, Hans de Goede wrote:
> On 7/17/20 5:19 PM, Linus Walleij wrote:
> > This makes the driver use the irqchip template to assign
> > properties to the gpio_irq_chip instead of using the
> > explicit calls to gpiochip_irqchip_add_nested() and
> > gpiochip_set_nested_irqchip(). The irqchip is instead
> > added while adding the gpiochip.
> > 
> > Cc: Bin Gao <bin.gao@linux.intel.com>
> > Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Cc: Hans de Goede <hdegoede@redhat.com>
> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> > ---
> > Same notices as on the Crystalcove: this one I actually
> > managed to compiletest properly.
> 
> I've given this patch a test-run on a machine with the
> Whiskey Cove PMIC and with the caveat that I've not
> actually tested the GPIO IRQ functionality, since that
> does not seem to be used on any machines, I see no adverse
> side effects from this patch, so it is:
> 
> Tested-by: Hans de Goede <hdegoede@redhat.com>

Applied to my branch, thanks!

Same for Crystal Cove.

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-17 15:19 [PATCH] gpio: wcove: Use irqchip template Linus Walleij
2020-07-22  8:57 ` Hans de Goede
2020-07-22 10:58   ` Andy Shevchenko

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
	public-inbox-index linux-gpio

Example config snippet for mirrors

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.git