Linux-GPIO Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v1 1/3] gpio: pca953x: Request IRQ after all initialisation done
@ 2020-07-28 12:55 Andy Shevchenko
  2020-07-28 12:55 ` [PATCH v1 2/3] gpio: crystalcove: Free IRQ on error path Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andy Shevchenko @ 2020-07-28 12:55 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, linux-gpio,
	Kuppuswamy Sathyanarayanan
  Cc: Andy Shevchenko

There is logically better to request IRQ when we initialise all structures.
Align the driver with the rest on the same matter.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-pca953x.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index ab22152bf3e8..bd2e96c34f82 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -865,17 +865,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip, int irq_base)
 	bitmap_and(chip->irq_stat, irq_stat, reg_direction, chip->gpio_chip.ngpio);
 	mutex_init(&chip->irq_lock);
 
-	ret = devm_request_threaded_irq(&client->dev, client->irq,
-					NULL, pca953x_irq_handler,
-					IRQF_ONESHOT | IRQF_SHARED,
-					dev_name(&client->dev), chip);
-	if (ret) {
-		dev_err(&client->dev, "failed to request irq %d\n",
-			client->irq);
-		return ret;
-	}
-
-	irq_chip->name = dev_name(&chip->client->dev);
+	irq_chip->name = dev_name(&client->dev);
 	irq_chip->irq_mask = pca953x_irq_mask;
 	irq_chip->irq_unmask = pca953x_irq_unmask;
 	irq_chip->irq_set_wake = pca953x_irq_set_wake;
@@ -895,6 +885,16 @@ static int pca953x_irq_setup(struct pca953x_chip *chip, int irq_base)
 	girq->threaded = true;
 	girq->first = irq_base; /* FIXME: get rid of this */
 
+	ret = devm_request_threaded_irq(&client->dev, client->irq,
+					NULL, pca953x_irq_handler,
+					IRQF_ONESHOT | IRQF_SHARED,
+					dev_name(&client->dev), chip);
+	if (ret) {
+		dev_err(&client->dev, "failed to request irq %d\n",
+			client->irq);
+		return ret;
+	}
+
 	return 0;
 }
 
-- 
2.27.0


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

* [PATCH v1 2/3] gpio: crystalcove: Free IRQ on error path
  2020-07-28 12:55 [PATCH v1 1/3] gpio: pca953x: Request IRQ after all initialisation done Andy Shevchenko
@ 2020-07-28 12:55 ` Andy Shevchenko
  2020-07-28 12:55 ` [PATCH v1 3/3] gpio: wcove: Request IRQ after all initialisation done Andy Shevchenko
  2020-08-03 23:26 ` [PATCH v1 1/3] gpio: pca953x: " Linus Walleij
  2 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2020-07-28 12:55 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, linux-gpio,
	Kuppuswamy Sathyanarayanan
  Cc: Andy Shevchenko

It appears that all, but request_irq(), calls in the driver are device managed.
In unlikely case of devm_gpiochip_add_data() failure the IRQ left requested.
Free IRQ on error path by switching to devm_request_threaded_irq() API.

Byproduct of this change is a drop of ->remove() callback completely.

Fixes: 945e72db36bd ("gpio: crystalcove: Use irqchip template")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-crystalcove.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/drivers/gpio/gpio-crystalcove.c b/drivers/gpio/gpio-crystalcove.c
index f60ff7579cd0..2ba225720086 100644
--- a/drivers/gpio/gpio-crystalcove.c
+++ b/drivers/gpio/gpio-crystalcove.c
@@ -364,9 +364,9 @@ static int crystalcove_gpio_probe(struct platform_device *pdev)
 	girq->handler = handle_simple_irq;
 	girq->threaded = true;
 
-	retval = request_threaded_irq(irq, NULL, crystalcove_gpio_irq_handler,
-				      IRQF_ONESHOT, KBUILD_MODNAME, cg);
-
+	retval = devm_request_threaded_irq(&pdev->dev, irq, NULL,
+					   crystalcove_gpio_irq_handler,
+					   IRQF_ONESHOT, KBUILD_MODNAME, cg);
 	if (retval) {
 		dev_warn(&pdev->dev, "request irq failed: %d\n", retval);
 		return retval;
@@ -381,24 +381,12 @@ static int crystalcove_gpio_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int crystalcove_gpio_remove(struct platform_device *pdev)
-{
-	struct crystalcove_gpio *cg = platform_get_drvdata(pdev);
-	int irq = platform_get_irq(pdev, 0);
-
-	if (irq >= 0)
-		free_irq(irq, cg);
-	return 0;
-}
-
 static struct platform_driver crystalcove_gpio_driver = {
 	.probe = crystalcove_gpio_probe,
-	.remove = crystalcove_gpio_remove,
 	.driver = {
 		.name = "crystal_cove_gpio",
 	},
 };
-
 module_platform_driver(crystalcove_gpio_driver);
 
 MODULE_AUTHOR("Yang, Bin <bin.yang@intel.com>");
-- 
2.27.0


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

* [PATCH v1 3/3] gpio: wcove: Request IRQ after all initialisation done
  2020-07-28 12:55 [PATCH v1 1/3] gpio: pca953x: Request IRQ after all initialisation done Andy Shevchenko
  2020-07-28 12:55 ` [PATCH v1 2/3] gpio: crystalcove: Free IRQ on error path Andy Shevchenko
@ 2020-07-28 12:55 ` Andy Shevchenko
  2020-08-03 23:26 ` [PATCH v1 1/3] gpio: pca953x: " Linus Walleij
  2 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2020-07-28 12:55 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, linux-gpio,
	Kuppuswamy Sathyanarayanan
  Cc: Andy Shevchenko

There is logically better to request IRQ when we initialise all structures.
Align the driver with the rest on the same matter.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-wcove.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c
index 135645096575..b5fbba5a783a 100644
--- a/drivers/gpio/gpio-wcove.c
+++ b/drivers/gpio/gpio-wcove.c
@@ -449,13 +449,6 @@ static int wcove_gpio_probe(struct platform_device *pdev)
 		return virq;
 	}
 
-	ret = devm_request_threaded_irq(dev, virq, NULL,
-		wcove_gpio_irq_handler, IRQF_ONESHOT, pdev->name, wg);
-	if (ret) {
-		dev_err(dev, "Failed to request irq %d\n", virq);
-		return ret;
-	}
-
 	girq = &wg->chip.irq;
 	girq->chip = &wcove_irqchip;
 	/* This will let us handle the parent IRQ in the driver */
@@ -466,6 +459,13 @@ static int wcove_gpio_probe(struct platform_device *pdev)
 	girq->handler = handle_simple_irq;
 	girq->threaded = true;
 
+	ret = devm_request_threaded_irq(dev, virq, NULL, wcove_gpio_irq_handler,
+					IRQF_ONESHOT, pdev->name, wg);
+	if (ret) {
+		dev_err(dev, "Failed to request irq %d\n", virq);
+		return ret;
+	}
+
 	ret = devm_gpiochip_add_data(dev, &wg->chip, wg);
 	if (ret) {
 		dev_err(dev, "Failed to add gpiochip: %d\n", ret);
-- 
2.27.0


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

* Re: [PATCH v1 1/3] gpio: pca953x: Request IRQ after all initialisation done
  2020-07-28 12:55 [PATCH v1 1/3] gpio: pca953x: Request IRQ after all initialisation done Andy Shevchenko
  2020-07-28 12:55 ` [PATCH v1 2/3] gpio: crystalcove: Free IRQ on error path Andy Shevchenko
  2020-07-28 12:55 ` [PATCH v1 3/3] gpio: wcove: Request IRQ after all initialisation done Andy Shevchenko
@ 2020-08-03 23:26 ` Linus Walleij
  2020-08-04  9:12   ` Andy Shevchenko
  2 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2020-08-03 23:26 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Bartosz Golaszewski, open list:GPIO SUBSYSTEM,
	Kuppuswamy Sathyanarayanan

On Tue, Jul 28, 2020 at 2:55 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> There is logically better to request IRQ when we initialise all structures.
> Align the driver with the rest on the same matter.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

I just applied these three (despite 2 & 3 hitting Intel drivers) since
we are in the
merge window and it needs to be in good shape for the merge.

Thanks!
Linus Walleij

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

* Re: [PATCH v1 1/3] gpio: pca953x: Request IRQ after all initialisation done
  2020-08-03 23:26 ` [PATCH v1 1/3] gpio: pca953x: " Linus Walleij
@ 2020-08-04  9:12   ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2020-08-04  9:12 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Bartosz Golaszewski, open list:GPIO SUBSYSTEM,
	Kuppuswamy Sathyanarayanan

On Tue, Aug 04, 2020 at 01:26:12AM +0200, Linus Walleij wrote:
> On Tue, Jul 28, 2020 at 2:55 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> 
> > There is logically better to request IRQ when we initialise all structures.
> > Align the driver with the rest on the same matter.

> I just applied these three
> (despite 2 & 3 hitting Intel drivers) since
> we are in the
> merge window and it needs to be in good shape for the merge.

That's exactly my understanding how it has to be proceeded.
Thanks!

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-28 12:55 [PATCH v1 1/3] gpio: pca953x: Request IRQ after all initialisation done Andy Shevchenko
2020-07-28 12:55 ` [PATCH v1 2/3] gpio: crystalcove: Free IRQ on error path Andy Shevchenko
2020-07-28 12:55 ` [PATCH v1 3/3] gpio: wcove: Request IRQ after all initialisation done Andy Shevchenko
2020-08-03 23:26 ` [PATCH v1 1/3] gpio: pca953x: " Linus Walleij
2020-08-04  9:12   ` 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