All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] gpio: use resource management for irq descriptors
@ 2017-03-04 16:23 Bartosz Golaszewski
  2017-03-04 16:23 ` [PATCH 01/12] gpio: mockup: use devm_irq_alloc_descs() Bartosz Golaszewski
                   ` (12 more replies)
  0 siblings, 13 replies; 32+ messages in thread
From: Bartosz Golaszewski @ 2017-03-04 16:23 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot, Bamvor Jian Zhang,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Robert Jarzmik
  Cc: linux-gpio, linux-kernel, linux-omap, Thomas Gleixner,
	Marc Zyngier, Bartosz Golaszewski

The following series uses the recently introduced set of
devm_irq_alloc_desc*() helpers in the GPIO drivers.

While we're at it: if the modified drivers called request_irq(), it
was changed to devm_request_irq() too.

Some drivers correctly clean up resources (e.g. gpio-mockup,
gpio-pch) - for them this change leads to an actual code shrink.

Other drivers are meant to be built-in and the devices they control
are never removed (e.g. gpio-pxa, gpio-davinci), so they deliberately
omit the cleanup. Still: in case something changes it's better to free
the resources - especially since these drivers already use other
devm_* routines like devm_kzalloc() etc.

The last group of drivers are the ones which can be compiled as
modules, but leak resources unintentionally (e.g. gpio-twl4030,
gpio-omap). This change fixes the interrupt descriptor leaks, but some
drivers will require additional work since they still don't release
other resources.

The following drivers were tested: gpio-mockup, gpio-omap
and gpio-davinci. The rest was compile-tested only.

Bartosz Golaszewski (12):
  gpio: mockup: use devm_irq_alloc_descs()
  gpio: twl4030: use devm_irq_alloc_descs()
  gpio: omap: use devm_irq_alloc_descs()
  gpio: pch: use resource management for irqs
  gpio: ml-ioh: use resource management for irqs
  gpio: xlp: use resource management for irqs
  gpio: pxa: use devm_irq_alloc_descs()
  gpio: davinci: use devm_irq_alloc_descs()
  gpio: sodaville: use resource management for irqs
  gpio: mxc: use devm_irq_alloc_descs()
  gpio: mxs: use devm_irq_alloc_descs()
  gpio: sta2x11: use resource management for irqs

 drivers/gpio/gpio-davinci.c   |  2 +-
 drivers/gpio/gpio-ml-ioh.c    | 28 +++++++---------------------
 drivers/gpio/gpio-mockup.c    | 16 +---------------
 drivers/gpio/gpio-mxc.c       |  6 ++----
 drivers/gpio/gpio-mxs.c       |  6 ++----
 drivers/gpio/gpio-omap.c      |  3 ++-
 drivers/gpio/gpio-pch.c       | 14 ++++----------
 drivers/gpio/gpio-pxa.c       |  2 +-
 drivers/gpio/gpio-sodaville.c | 28 +++++++++++-----------------
 drivers/gpio/gpio-sta2x11.c   | 17 ++++++-----------
 drivers/gpio/gpio-twl4030.c   |  3 ++-
 drivers/gpio/gpio-xlp.c       |  8 ++++----
 12 files changed, 43 insertions(+), 90 deletions(-)

-- 
2.9.3


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

* [PATCH 01/12] gpio: mockup: use devm_irq_alloc_descs()
  2017-03-04 16:23 [PATCH 00/12] gpio: use resource management for irq descriptors Bartosz Golaszewski
@ 2017-03-04 16:23 ` Bartosz Golaszewski
  2017-03-08  8:21   ` Bamvor Zhang Jian
  2017-03-14 15:08   ` Linus Walleij
  2017-03-04 16:23 ` [PATCH 02/12] gpio: twl4030: " Bartosz Golaszewski
                   ` (11 subsequent siblings)
  12 siblings, 2 replies; 32+ messages in thread
From: Bartosz Golaszewski @ 2017-03-04 16:23 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot, Bamvor Jian Zhang,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Robert Jarzmik
  Cc: linux-gpio, linux-kernel, linux-omap, Thomas Gleixner,
	Marc Zyngier, Bartosz Golaszewski

Use the resource managed variant of irq_alloc_descs(). This allows us
to remove gpio_mockup_remove().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/gpio/gpio-mockup.c | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index 06dac72..37c2d69 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -169,7 +169,7 @@ static int gpio_mockup_irqchip_setup(struct device *dev,
 	struct gpio_chip *gc = &chip->gc;
 	int irq_base, i;
 
-	irq_base = irq_alloc_descs(-1, 0, gc->ngpio, 0);
+	irq_base = devm_irq_alloc_descs(dev, -1, 0, gc->ngpio, 0);
 	if (irq_base < 0)
 		return irq_base;
 
@@ -373,25 +373,11 @@ static int gpio_mockup_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int gpio_mockup_remove(struct platform_device *pdev)
-{
-	struct gpio_mockup_chip *chips;
-	int i;
-
-	chips = platform_get_drvdata(pdev);
-
-	for (i = 0; i < gpio_mockup_params_nr >> 1; i++)
-		irq_free_descs(chips[i].gc.irq_base, chips[i].gc.ngpio);
-
-	return 0;
-}
-
 static struct platform_driver gpio_mockup_driver = {
 	.driver = {
 		.name = GPIO_MOCKUP_NAME,
 	},
 	.probe = gpio_mockup_probe,
-	.remove = gpio_mockup_remove,
 };
 
 static struct platform_device *pdev;
-- 
2.9.3

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

* [PATCH 02/12] gpio: twl4030: use devm_irq_alloc_descs()
  2017-03-04 16:23 [PATCH 00/12] gpio: use resource management for irq descriptors Bartosz Golaszewski
  2017-03-04 16:23 ` [PATCH 01/12] gpio: mockup: use devm_irq_alloc_descs() Bartosz Golaszewski
@ 2017-03-04 16:23 ` Bartosz Golaszewski
  2017-03-14 15:08   ` Linus Walleij
  2017-03-04 16:23 ` [PATCH 03/12] gpio: omap: " Bartosz Golaszewski
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 32+ messages in thread
From: Bartosz Golaszewski @ 2017-03-04 16:23 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot, Bamvor Jian Zhang,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Robert Jarzmik
  Cc: linux-gpio, linux-kernel, linux-omap, Thomas Gleixner,
	Marc Zyngier, Bartosz Golaszewski

This driver never frees the irq descriptors it allocates. Fix it by
using a resource managed variant of irq_alloc_descs().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/gpio/gpio-twl4030.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
index dfcfbba..24f388e 100644
--- a/drivers/gpio/gpio-twl4030.c
+++ b/drivers/gpio/gpio-twl4030.c
@@ -485,7 +485,8 @@ static int gpio_twl4030_probe(struct platform_device *pdev)
 		goto no_irqs;
 	}
 
-	irq_base = irq_alloc_descs(-1, 0, TWL4030_GPIO_MAX, 0);
+	irq_base = devm_irq_alloc_descs(&pdev->dev, -1,
+					0, TWL4030_GPIO_MAX, 0);
 	if (irq_base < 0) {
 		dev_err(&pdev->dev, "Failed to alloc irq_descs\n");
 		return irq_base;
-- 
2.9.3

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

* [PATCH 03/12] gpio: omap: use devm_irq_alloc_descs()
  2017-03-04 16:23 [PATCH 00/12] gpio: use resource management for irq descriptors Bartosz Golaszewski
  2017-03-04 16:23 ` [PATCH 01/12] gpio: mockup: use devm_irq_alloc_descs() Bartosz Golaszewski
  2017-03-04 16:23 ` [PATCH 02/12] gpio: twl4030: " Bartosz Golaszewski
@ 2017-03-04 16:23 ` Bartosz Golaszewski
  2017-03-06 16:50   ` Tony Lindgren
  2017-03-14 15:09   ` Linus Walleij
  2017-03-04 16:23 ` [PATCH 04/12] gpio: pch: use resource management for irqs Bartosz Golaszewski
                   ` (9 subsequent siblings)
  12 siblings, 2 replies; 32+ messages in thread
From: Bartosz Golaszewski @ 2017-03-04 16:23 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot, Bamvor Jian Zhang,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Robert Jarzmik
  Cc: linux-gpio, linux-kernel, linux-omap, Thomas Gleixner,
	Marc Zyngier, Bartosz Golaszewski

This driver never frees the allocated interrupt descriptors. Fix it by
using a resource managed variant of irq_alloc_descs().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/gpio/gpio-omap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index efc85a2..5d6a574 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1085,7 +1085,8 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc)
 	 * REVISIT: Once we have OMAP1 supporting SPARSE_IRQ, we can drop
 	 * irq_alloc_descs() since a base IRQ offset will no longer be needed.
 	 */
-	irq_base = irq_alloc_descs(-1, 0, bank->width, 0);
+	irq_base = devm_irq_alloc_descs(bank->chip.parent,
+					-1, 0, bank->width, 0);
 	if (irq_base < 0) {
 		dev_err(bank->chip.parent, "Couldn't allocate IRQ numbers\n");
 		return -ENODEV;
-- 
2.9.3


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

* [PATCH 04/12] gpio: pch: use resource management for irqs
  2017-03-04 16:23 [PATCH 00/12] gpio: use resource management for irq descriptors Bartosz Golaszewski
                   ` (2 preceding siblings ...)
  2017-03-04 16:23 ` [PATCH 03/12] gpio: omap: " Bartosz Golaszewski
@ 2017-03-04 16:23 ` Bartosz Golaszewski
  2017-03-14 15:10   ` Linus Walleij
  2017-03-04 16:23 ` [PATCH 05/12] gpio: ml-ioh: " Bartosz Golaszewski
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 32+ messages in thread
From: Bartosz Golaszewski @ 2017-03-04 16:23 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot, Bamvor Jian Zhang,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Robert Jarzmik
  Cc: linux-gpio, linux-kernel, linux-omap, Thomas Gleixner,
	Marc Zyngier, Bartosz Golaszewski

Use device resource managed variants of irq_alloc_descs() and
request_irq() and remove the code manually freeing irq resources.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/gpio/gpio-pch.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/gpio/gpio-pch.c b/drivers/gpio/gpio-pch.c
index 7c7135d..71bc6da 100644
--- a/drivers/gpio/gpio-pch.c
+++ b/drivers/gpio/gpio-pch.c
@@ -403,7 +403,8 @@ static int pch_gpio_probe(struct pci_dev *pdev,
 		goto err_gpiochip_add;
 	}
 
-	irq_base = irq_alloc_descs(-1, 0, gpio_pins[chip->ioh], NUMA_NO_NODE);
+	irq_base = devm_irq_alloc_descs(&pdev->dev, -1, 0,
+					gpio_pins[chip->ioh], NUMA_NO_NODE);
 	if (irq_base < 0) {
 		dev_warn(&pdev->dev, "PCH gpio: Failed to get IRQ base num\n");
 		chip->irq_base = -1;
@@ -416,8 +417,8 @@ static int pch_gpio_probe(struct pci_dev *pdev,
 	iowrite32(msk, &chip->reg->imask);
 	iowrite32(msk, &chip->reg->ien);
 
-	ret = request_irq(pdev->irq, pch_gpio_handler,
-			  IRQF_SHARED, KBUILD_MODNAME, chip);
+	ret = devm_request_irq(&pdev->dev, pdev->irq, pch_gpio_handler,
+			       IRQF_SHARED, KBUILD_MODNAME, chip);
 	if (ret != 0) {
 		dev_err(&pdev->dev,
 			"%s request_irq failed\n", __func__);
@@ -430,7 +431,6 @@ static int pch_gpio_probe(struct pci_dev *pdev,
 	return 0;
 
 err_request_irq:
-	irq_free_descs(irq_base, gpio_pins[chip->ioh]);
 	gpiochip_remove(&chip->gpio);
 
 err_gpiochip_add:
@@ -452,12 +452,6 @@ static void pch_gpio_remove(struct pci_dev *pdev)
 {
 	struct pch_gpio *chip = pci_get_drvdata(pdev);
 
-	if (chip->irq_base != -1) {
-		free_irq(pdev->irq, chip);
-
-		irq_free_descs(chip->irq_base, gpio_pins[chip->ioh]);
-	}
-
 	gpiochip_remove(&chip->gpio);
 	pci_iounmap(pdev, chip->base);
 	pci_release_regions(pdev);
-- 
2.9.3


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

* [PATCH 05/12] gpio: ml-ioh: use resource management for irqs
  2017-03-04 16:23 [PATCH 00/12] gpio: use resource management for irq descriptors Bartosz Golaszewski
                   ` (3 preceding siblings ...)
  2017-03-04 16:23 ` [PATCH 04/12] gpio: pch: use resource management for irqs Bartosz Golaszewski
@ 2017-03-04 16:23 ` Bartosz Golaszewski
  2017-03-14 15:11   ` Linus Walleij
  2017-03-04 16:23 ` [PATCH 06/12] gpio: xlp: " Bartosz Golaszewski
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 32+ messages in thread
From: Bartosz Golaszewski @ 2017-03-04 16:23 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot, Bamvor Jian Zhang,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Robert Jarzmik
  Cc: linux-gpio, linux-kernel, linux-omap, Thomas Gleixner,
	Marc Zyngier, Bartosz Golaszewski

Use device resource managed variants of irq_alloc_descs() and
request_irq() and remove the code manually freeing irq resources.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/gpio/gpio-ml-ioh.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/drivers/gpio/gpio-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c
index 796a5a4..78896a8 100644
--- a/drivers/gpio/gpio-ml-ioh.c
+++ b/drivers/gpio/gpio-ml-ioh.c
@@ -459,41 +459,31 @@ static int ioh_gpio_probe(struct pci_dev *pdev,
 
 	chip = chip_save;
 	for (j = 0; j < 8; j++, chip++) {
-		irq_base = irq_alloc_descs(-1, IOH_IRQ_BASE, num_ports[j],
-					   NUMA_NO_NODE);
+		irq_base = devm_irq_alloc_descs(&pdev->dev, -1, IOH_IRQ_BASE,
+						num_ports[j], NUMA_NO_NODE);
 		if (irq_base < 0) {
 			dev_warn(&pdev->dev,
 				"ml_ioh_gpio: Failed to get IRQ base num\n");
-			chip->irq_base = -1;
 			ret = irq_base;
-			goto err_irq_alloc_descs;
+			goto err_gpiochip_add;
 		}
 		chip->irq_base = irq_base;
 		ioh_gpio_alloc_generic_chip(chip, irq_base, num_ports[j]);
 	}
 
 	chip = chip_save;
-	ret = request_irq(pdev->irq, ioh_gpio_handler,
-			     IRQF_SHARED, KBUILD_MODNAME, chip);
+	ret = devm_request_irq(&pdev->dev, pdev->irq, ioh_gpio_handler,
+			       IRQF_SHARED, KBUILD_MODNAME, chip);
 	if (ret != 0) {
 		dev_err(&pdev->dev,
 			"%s request_irq failed\n", __func__);
-		goto err_request_irq;
+		goto err_gpiochip_add;
 	}
 
 	pci_set_drvdata(pdev, chip);
 
 	return 0;
 
-err_request_irq:
-	chip = chip_save;
-err_irq_alloc_descs:
-	while (--j >= 0) {
-		chip--;
-		irq_free_descs(chip->irq_base, num_ports[j]);
-	}
-
-	chip = chip_save;
 err_gpiochip_add:
 	while (--i >= 0) {
 		chip--;
@@ -524,12 +514,8 @@ static void ioh_gpio_remove(struct pci_dev *pdev)
 
 	chip_save = chip;
 
-	free_irq(pdev->irq, chip);
-
-	for (i = 0; i < 8; i++, chip++) {
-		irq_free_descs(chip->irq_base, num_ports[i]);
+	for (i = 0; i < 8; i++, chip++)
 		gpiochip_remove(&chip->gpio);
-	}
 
 	chip = chip_save;
 	pci_iounmap(pdev, chip->base);
-- 
2.9.3

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

* [PATCH 06/12] gpio: xlp: use resource management for irqs
  2017-03-04 16:23 [PATCH 00/12] gpio: use resource management for irq descriptors Bartosz Golaszewski
                   ` (4 preceding siblings ...)
  2017-03-04 16:23 ` [PATCH 05/12] gpio: ml-ioh: " Bartosz Golaszewski
@ 2017-03-04 16:23 ` Bartosz Golaszewski
  2017-03-14 15:11   ` Linus Walleij
  2017-03-04 16:23 ` [PATCH 07/12] gpio: pxa: use devm_irq_alloc_descs() Bartosz Golaszewski
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 32+ messages in thread
From: Bartosz Golaszewski @ 2017-03-04 16:23 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot, Bamvor Jian Zhang,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Robert Jarzmik
  Cc: linux-gpio, linux-kernel, linux-omap, Thomas Gleixner,
	Marc Zyngier, Bartosz Golaszewski

Use the resource managed variant of irq_alloc_descs() and remove the
code manually freeing allocated interrupt descriptors.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/gpio/gpio-xlp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-xlp.c b/drivers/gpio/gpio-xlp.c
index 4620d05..7cc82cf 100644
--- a/drivers/gpio/gpio-xlp.c
+++ b/drivers/gpio/gpio-xlp.c
@@ -404,7 +404,9 @@ static int xlp_gpio_probe(struct platform_device *pdev)
 
 	/* XLP(MIPS) has fixed range for GPIO IRQs, Vulcan(ARM64) does not */
 	if (soc_type != GPIO_VARIANT_VULCAN) {
-		irq_base = irq_alloc_descs(-1, XLP_GPIO_IRQ_BASE, gc->ngpio, 0);
+		irq_base = devm_irq_alloc_descs(&pdev->dev, -1,
+						XLP_GPIO_IRQ_BASE,
+						gc->ngpio, 0);
 		if (irq_base < 0) {
 			dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n");
 			return irq_base;
@@ -415,7 +417,7 @@ static int xlp_gpio_probe(struct platform_device *pdev)
 
 	err = gpiochip_add_data(gc, priv);
 	if (err < 0)
-		goto out_free_desc;
+		return err;
 
 	err = gpiochip_irqchip_add(gc, &xlp_gpio_irq_chip, irq_base,
 				handle_level_irq, IRQ_TYPE_NONE);
@@ -433,8 +435,6 @@ static int xlp_gpio_probe(struct platform_device *pdev)
 
 out_gpio_remove:
 	gpiochip_remove(gc);
-out_free_desc:
-	irq_free_descs(irq_base, gc->ngpio);
 	return err;
 }
 
-- 
2.9.3


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

* [PATCH 07/12] gpio: pxa: use devm_irq_alloc_descs()
  2017-03-04 16:23 [PATCH 00/12] gpio: use resource management for irq descriptors Bartosz Golaszewski
                   ` (5 preceding siblings ...)
  2017-03-04 16:23 ` [PATCH 06/12] gpio: xlp: " Bartosz Golaszewski
@ 2017-03-04 16:23 ` Bartosz Golaszewski
  2017-03-04 20:31   ` Robert Jarzmik
  2017-03-14 15:12   ` Linus Walleij
  2017-03-04 16:23 ` [PATCH 08/12] gpio: davinci: " Bartosz Golaszewski
                   ` (5 subsequent siblings)
  12 siblings, 2 replies; 32+ messages in thread
From: Bartosz Golaszewski @ 2017-03-04 16:23 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot, Bamvor Jian Zhang,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Robert Jarzmik
  Cc: linux-gpio, linux-kernel, linux-omap, Thomas Gleixner,
	Marc Zyngier, Bartosz Golaszewski

This driver never frees the interrupt descriptors it allocates. Fix
it by using the resource managed version of irq_alloc_descs().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/gpio/gpio-pxa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 76ac906..832f3e4 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -601,7 +601,7 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev,
 	nr_gpios = gpio_id->gpio_nums;
 	pxa_last_gpio = nr_gpios - 1;
 
-	irq_base = irq_alloc_descs(-1, 0, nr_gpios, 0);
+	irq_base = devm_irq_alloc_descs(&pdev->dev, -1, 0, nr_gpios, 0);
 	if (irq_base < 0) {
 		dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n");
 		return irq_base;
-- 
2.9.3


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

* [PATCH 08/12] gpio: davinci: use devm_irq_alloc_descs()
  2017-03-04 16:23 [PATCH 00/12] gpio: use resource management for irq descriptors Bartosz Golaszewski
                   ` (6 preceding siblings ...)
  2017-03-04 16:23 ` [PATCH 07/12] gpio: pxa: use devm_irq_alloc_descs() Bartosz Golaszewski
@ 2017-03-04 16:23 ` Bartosz Golaszewski
  2017-03-06  4:59     ` Keerthy
  2017-03-14 15:13   ` Linus Walleij
  2017-03-04 16:23 ` [PATCH 09/12] gpio: sodaville: use resource management for irqs Bartosz Golaszewski
                   ` (4 subsequent siblings)
  12 siblings, 2 replies; 32+ messages in thread
From: Bartosz Golaszewski @ 2017-03-04 16:23 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot, Bamvor Jian Zhang,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Robert Jarzmik
  Cc: linux-gpio, linux-kernel, linux-omap, Thomas Gleixner,
	Marc Zyngier, Bartosz Golaszewski

This driver never frees the interrupt descriptors it allocates. Fix
it by using the resource managed version of irq_alloc_descs().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/gpio/gpio-davinci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index 72f49d1..ac17357 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -483,7 +483,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
 	clk_prepare_enable(clk);
 
 	if (!pdata->gpio_unbanked) {
-		irq = irq_alloc_descs(-1, 0, ngpio, 0);
+		irq = devm_irq_alloc_descs(dev, -1, 0, ngpio, 0);
 		if (irq < 0) {
 			dev_err(dev, "Couldn't allocate IRQ numbers\n");
 			return irq;
-- 
2.9.3

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

* [PATCH 09/12] gpio: sodaville: use resource management for irqs
  2017-03-04 16:23 [PATCH 00/12] gpio: use resource management for irq descriptors Bartosz Golaszewski
                   ` (7 preceding siblings ...)
  2017-03-04 16:23 ` [PATCH 08/12] gpio: davinci: " Bartosz Golaszewski
@ 2017-03-04 16:23 ` Bartosz Golaszewski
  2017-03-14 15:14   ` Linus Walleij
  2017-03-04 16:23 ` [PATCH 10/12] gpio: mxc: use devm_irq_alloc_descs() Bartosz Golaszewski
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 32+ messages in thread
From: Bartosz Golaszewski @ 2017-03-04 16:23 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot, Bamvor Jian Zhang,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Robert Jarzmik
  Cc: linux-gpio, linux-kernel, linux-omap, Thomas Gleixner,
	Marc Zyngier, Bartosz Golaszewski

Use device resource managed variants of irq_alloc_descs() and
request_irq() and remove the code manually freeing irq resources.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/gpio/gpio-sodaville.c | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/gpio/gpio-sodaville.c b/drivers/gpio/gpio-sodaville.c
index 7da9e6c..f60da83 100644
--- a/drivers/gpio/gpio-sodaville.c
+++ b/drivers/gpio/gpio-sodaville.c
@@ -135,7 +135,8 @@ static int sdv_register_irqsupport(struct sdv_gpio_chip_data *sd,
 	struct irq_chip_type *ct;
 	int ret;
 
-	sd->irq_base = irq_alloc_descs(-1, 0, SDV_NUM_PUB_GPIOS, -1);
+	sd->irq_base = devm_irq_alloc_descs(&pdev->dev, -1, 0,
+					    SDV_NUM_PUB_GPIOS, -1);
 	if (sd->irq_base < 0)
 		return sd->irq_base;
 
@@ -143,10 +144,11 @@ static int sdv_register_irqsupport(struct sdv_gpio_chip_data *sd,
 	writel(0, sd->gpio_pub_base + GPIO_INT);
 	writel((1 << 11) - 1, sd->gpio_pub_base + GPSTR);
 
-	ret = request_irq(pdev->irq, sdv_gpio_pub_irq_handler, IRQF_SHARED,
-			"sdv_gpio", sd);
+	ret = devm_request_irq(&pdev->dev, pdev->irq,
+			       sdv_gpio_pub_irq_handler, IRQF_SHARED,
+			       "sdv_gpio", sd);
 	if (ret)
-		goto out_free_desc;
+		return ret;
 
 	/*
 	 * This gpio irq controller latches level irqs. Testing shows that if
@@ -155,10 +157,8 @@ static int sdv_register_irqsupport(struct sdv_gpio_chip_data *sd,
 	 */
 	sd->gc = irq_alloc_generic_chip("sdv-gpio", 1, sd->irq_base,
 			sd->gpio_pub_base, handle_fasteoi_irq);
-	if (!sd->gc) {
-		ret = -ENOMEM;
-		goto out_free_irq;
-	}
+	if (!sd->gc)
+		return -ENOMEM;
 
 	sd->gc->private = sd;
 	ct = sd->gc->chip_types;
@@ -176,16 +176,10 @@ static int sdv_register_irqsupport(struct sdv_gpio_chip_data *sd,
 
 	sd->id = irq_domain_add_legacy(pdev->dev.of_node, SDV_NUM_PUB_GPIOS,
 				sd->irq_base, 0, &irq_domain_sdv_ops, sd);
-	if (!sd->id) {
-		ret = -ENODEV;
-		goto out_free_irq;
-	}
+	if (!sd->id)
+		return -ENODEV;
+
 	return 0;
-out_free_irq:
-	free_irq(pdev->irq, sd);
-out_free_desc:
-	irq_free_descs(sd->irq_base, SDV_NUM_PUB_GPIOS);
-	return ret;
 }
 
 static int sdv_gpio_probe(struct pci_dev *pdev,
-- 
2.9.3

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

* [PATCH 10/12] gpio: mxc: use devm_irq_alloc_descs()
  2017-03-04 16:23 [PATCH 00/12] gpio: use resource management for irq descriptors Bartosz Golaszewski
                   ` (8 preceding siblings ...)
  2017-03-04 16:23 ` [PATCH 09/12] gpio: sodaville: use resource management for irqs Bartosz Golaszewski
@ 2017-03-04 16:23 ` Bartosz Golaszewski
  2017-03-14 15:15   ` Linus Walleij
  2017-03-04 16:23 ` [PATCH 11/12] gpio: mxs: " Bartosz Golaszewski
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 32+ messages in thread
From: Bartosz Golaszewski @ 2017-03-04 16:23 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot, Bamvor Jian Zhang,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Robert Jarzmik
  Cc: linux-gpio, linux-kernel, linux-omap, Thomas Gleixner,
	Marc Zyngier, Bartosz Golaszewski

This driver never frees the interrupt descriptors it allocates. Fix
it by using the resource managed version of irq_alloc_descs().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/gpio/gpio-mxc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
index c1a1e00..3abea3f 100644
--- a/drivers/gpio/gpio-mxc.c
+++ b/drivers/gpio/gpio-mxc.c
@@ -471,7 +471,7 @@ static int mxc_gpio_probe(struct platform_device *pdev)
 	if (err)
 		goto out_bgio;
 
-	irq_base = irq_alloc_descs(-1, 0, 32, numa_node_id());
+	irq_base = devm_irq_alloc_descs(&pdev->dev, -1, 0, 32, numa_node_id());
 	if (irq_base < 0) {
 		err = irq_base;
 		goto out_bgio;
@@ -481,7 +481,7 @@ static int mxc_gpio_probe(struct platform_device *pdev)
 					     &irq_domain_simple_ops, NULL);
 	if (!port->domain) {
 		err = -ENODEV;
-		goto out_irqdesc_free;
+		goto out_bgio;
 	}
 
 	/* gpio-mxc can be a generic irq chip */
@@ -495,8 +495,6 @@ static int mxc_gpio_probe(struct platform_device *pdev)
 
 out_irqdomain_remove:
 	irq_domain_remove(port->domain);
-out_irqdesc_free:
-	irq_free_descs(irq_base, 32);
 out_bgio:
 	dev_info(&pdev->dev, "%s failed with errno %d\n", __func__, err);
 	return err;
-- 
2.9.3


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

* [PATCH 11/12] gpio: mxs: use devm_irq_alloc_descs()
  2017-03-04 16:23 [PATCH 00/12] gpio: use resource management for irq descriptors Bartosz Golaszewski
                   ` (9 preceding siblings ...)
  2017-03-04 16:23 ` [PATCH 10/12] gpio: mxc: use devm_irq_alloc_descs() Bartosz Golaszewski
@ 2017-03-04 16:23 ` Bartosz Golaszewski
  2017-03-14 15:16   ` Linus Walleij
  2017-03-04 16:23 ` [PATCH 12/12] gpio: sta2x11: use resource management for irqs Bartosz Golaszewski
  2017-03-14 15:18 ` [PATCH 00/12] gpio: use resource management for irq descriptors Linus Walleij
  12 siblings, 1 reply; 32+ messages in thread
From: Bartosz Golaszewski @ 2017-03-04 16:23 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot, Bamvor Jian Zhang,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Robert Jarzmik
  Cc: linux-gpio, linux-kernel, linux-omap, Thomas Gleixner,
	Marc Zyngier, Bartosz Golaszewski

This driver never frees the interrupt descriptors it allocates. Fix
it by using the resource managed version of irq_alloc_descs().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/gpio/gpio-mxs.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
index 2292742..6ae583f 100644
--- a/drivers/gpio/gpio-mxs.c
+++ b/drivers/gpio/gpio-mxs.c
@@ -328,7 +328,7 @@ static int mxs_gpio_probe(struct platform_device *pdev)
 	/* clear address has to be used to clear IRQSTAT bits */
 	writel(~0U, port->base + PINCTRL_IRQSTAT(port) + MXS_CLR);
 
-	irq_base = irq_alloc_descs(-1, 0, 32, numa_node_id());
+	irq_base = devm_irq_alloc_descs(&pdev->dev, -1, 0, 32, numa_node_id());
 	if (irq_base < 0) {
 		err = irq_base;
 		goto out_iounmap;
@@ -338,7 +338,7 @@ static int mxs_gpio_probe(struct platform_device *pdev)
 					     &irq_domain_simple_ops, NULL);
 	if (!port->domain) {
 		err = -ENODEV;
-		goto out_irqdesc_free;
+		goto out_iounmap;
 	}
 
 	/* gpio-mxs can be a generic irq chip */
@@ -370,8 +370,6 @@ static int mxs_gpio_probe(struct platform_device *pdev)
 
 out_irqdomain_remove:
 	irq_domain_remove(port->domain);
-out_irqdesc_free:
-	irq_free_descs(irq_base, 32);
 out_iounmap:
 	iounmap(port->base);
 	return err;
-- 
2.9.3

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

* [PATCH 12/12] gpio: sta2x11: use resource management for irqs
  2017-03-04 16:23 [PATCH 00/12] gpio: use resource management for irq descriptors Bartosz Golaszewski
                   ` (10 preceding siblings ...)
  2017-03-04 16:23 ` [PATCH 11/12] gpio: mxs: " Bartosz Golaszewski
@ 2017-03-04 16:23 ` Bartosz Golaszewski
  2017-03-14 15:16   ` Linus Walleij
  2017-03-14 15:18 ` [PATCH 00/12] gpio: use resource management for irq descriptors Linus Walleij
  12 siblings, 1 reply; 32+ messages in thread
From: Bartosz Golaszewski @ 2017-03-04 16:23 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot, Bamvor Jian Zhang,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Robert Jarzmik
  Cc: linux-gpio, linux-kernel, linux-omap, Thomas Gleixner,
	Marc Zyngier, Bartosz Golaszewski

Use device resource managed variants of irq_alloc_descs() and
request_irq() and remove the code manually freeing irq resources.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/gpio/gpio-sta2x11.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-sta2x11.c b/drivers/gpio/gpio-sta2x11.c
index 853ca23..39df062 100644
--- a/drivers/gpio/gpio-sta2x11.c
+++ b/drivers/gpio/gpio-sta2x11.c
@@ -392,7 +392,8 @@ static int gsta_probe(struct platform_device *dev)
 			gsta_set_config(chip, i, gpio_pdata->pinconfig[i]);
 
 	/* 384 was used in previous code: be compatible for other drivers */
-	err = irq_alloc_descs(-1, 384, GSTA_NR_GPIO, NUMA_NO_NODE);
+	err = devm_irq_alloc_descs(&dev->dev, -1, 384,
+				   GSTA_NR_GPIO, NUMA_NO_NODE);
 	if (err < 0) {
 		dev_warn(&dev->dev, "sta2x11 gpio: Can't get irq base (%i)\n",
 			 -err);
@@ -401,29 +402,23 @@ static int gsta_probe(struct platform_device *dev)
 	chip->irq_base = err;
 	gsta_alloc_irq_chip(chip);
 
-	err = request_irq(pdev->irq, gsta_gpio_handler,
-			     IRQF_SHARED, KBUILD_MODNAME, chip);
+	err = devm_request_irq(&dev->dev, pdev->irq, gsta_gpio_handler,
+			       IRQF_SHARED, KBUILD_MODNAME, chip);
 	if (err < 0) {
 		dev_err(&dev->dev, "sta2x11 gpio: Can't request irq (%i)\n",
 			-err);
-		goto err_free_descs;
+		return err;
 	}
 
 	err = devm_gpiochip_add_data(&dev->dev, &chip->gpio, chip);
 	if (err < 0) {
 		dev_err(&dev->dev, "sta2x11 gpio: Can't register (%i)\n",
 			-err);
-		goto err_free_irq;
+		return err;
 	}
 
 	platform_set_drvdata(dev, chip);
 	return 0;
-
-err_free_irq:
-	free_irq(pdev->irq, chip);
-err_free_descs:
-	irq_free_descs(chip->irq_base, GSTA_NR_GPIO);
-	return err;
 }
 
 static struct platform_driver sta2x11_gpio_platform_driver = {
-- 
2.9.3

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

* Re: [PATCH 07/12] gpio: pxa: use devm_irq_alloc_descs()
  2017-03-04 16:23 ` [PATCH 07/12] gpio: pxa: use devm_irq_alloc_descs() Bartosz Golaszewski
@ 2017-03-04 20:31   ` Robert Jarzmik
  2017-03-14 15:12   ` Linus Walleij
  1 sibling, 0 replies; 32+ messages in thread
From: Robert Jarzmik @ 2017-03-04 20:31 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Alexandre Courbot, Bamvor Jian Zhang,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman, linux-gpio,
	linux-kernel, linux-omap, Thomas Gleixner, Marc Zyngier

Bartosz Golaszewski <bgolaszewski@baylibre.com> writes:

> This driver never frees the interrupt descriptors it allocates. Fix
> it by using the resource managed version of irq_alloc_descs().
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>

-- 
Robert

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

* Re: [PATCH 08/12] gpio: davinci: use devm_irq_alloc_descs()
  2017-03-04 16:23 ` [PATCH 08/12] gpio: davinci: " Bartosz Golaszewski
@ 2017-03-06  4:59     ` Keerthy
  2017-03-14 15:13   ` Linus Walleij
  1 sibling, 0 replies; 32+ messages in thread
From: Keerthy @ 2017-03-06  4:59 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij, Alexandre Courbot,
	Bamvor Jian Zhang, Grygorii Strashko, Santosh Shilimkar,
	Kevin Hilman, Robert Jarzmik
  Cc: linux-gpio, linux-kernel, linux-omap, Thomas Gleixner, Marc Zyngier



On Saturday 04 March 2017 09:53 PM, Bartosz Golaszewski wrote:
> This driver never frees the interrupt descriptors it allocates. Fix
> it by using the resource managed version of irq_alloc_descs().
>

Acked-by: Keerthy <j-keerthy@ti.com>

> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
>  drivers/gpio/gpio-davinci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
> index 72f49d1..ac17357 100644
> --- a/drivers/gpio/gpio-davinci.c
> +++ b/drivers/gpio/gpio-davinci.c
> @@ -483,7 +483,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
>  	clk_prepare_enable(clk);
>
>  	if (!pdata->gpio_unbanked) {
> -		irq = irq_alloc_descs(-1, 0, ngpio, 0);
> +		irq = devm_irq_alloc_descs(dev, -1, 0, ngpio, 0);
>  		if (irq < 0) {
>  			dev_err(dev, "Couldn't allocate IRQ numbers\n");
>  			return irq;
>

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

* Re: [PATCH 08/12] gpio: davinci: use devm_irq_alloc_descs()
@ 2017-03-06  4:59     ` Keerthy
  0 siblings, 0 replies; 32+ messages in thread
From: Keerthy @ 2017-03-06  4:59 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij, Alexandre Courbot,
	Bamvor Jian Zhang, Grygorii Strashko, Santosh Shilimkar,
	Kevin Hilman, Robert Jarzmik
  Cc: linux-gpio, linux-kernel, linux-omap, Thomas Gleixner, Marc Zyngier



On Saturday 04 March 2017 09:53 PM, Bartosz Golaszewski wrote:
> This driver never frees the interrupt descriptors it allocates. Fix
> it by using the resource managed version of irq_alloc_descs().
>

Acked-by: Keerthy <j-keerthy@ti.com>

> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
>  drivers/gpio/gpio-davinci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
> index 72f49d1..ac17357 100644
> --- a/drivers/gpio/gpio-davinci.c
> +++ b/drivers/gpio/gpio-davinci.c
> @@ -483,7 +483,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
>  	clk_prepare_enable(clk);
>
>  	if (!pdata->gpio_unbanked) {
> -		irq = irq_alloc_descs(-1, 0, ngpio, 0);
> +		irq = devm_irq_alloc_descs(dev, -1, 0, ngpio, 0);
>  		if (irq < 0) {
>  			dev_err(dev, "Couldn't allocate IRQ numbers\n");
>  			return irq;
>

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

* Re: [PATCH 03/12] gpio: omap: use devm_irq_alloc_descs()
  2017-03-04 16:23 ` [PATCH 03/12] gpio: omap: " Bartosz Golaszewski
@ 2017-03-06 16:50   ` Tony Lindgren
  2017-03-14 15:09   ` Linus Walleij
  1 sibling, 0 replies; 32+ messages in thread
From: Tony Lindgren @ 2017-03-06 16:50 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Alexandre Courbot, Bamvor Jian Zhang,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Robert Jarzmik, linux-gpio, linux-kernel, linux-omap,
	Thomas Gleixner, Marc Zyngier, Aaro Koskinen

* Bartosz Golaszewski <bgolaszewski@baylibre.com> [170304 08:33]:
> This driver never frees the allocated interrupt descriptors. Fix it by
> using a resource managed variant of irq_alloc_descs().
> 
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Would be good to get Aaro's ack on this one.

Regards,

Tony

> ---
>  drivers/gpio/gpio-omap.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index efc85a2..5d6a574 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -1085,7 +1085,8 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc)
>  	 * REVISIT: Once we have OMAP1 supporting SPARSE_IRQ, we can drop
>  	 * irq_alloc_descs() since a base IRQ offset will no longer be needed.
>  	 */
> -	irq_base = irq_alloc_descs(-1, 0, bank->width, 0);
> +	irq_base = devm_irq_alloc_descs(bank->chip.parent,
> +					-1, 0, bank->width, 0);
>  	if (irq_base < 0) {
>  		dev_err(bank->chip.parent, "Couldn't allocate IRQ numbers\n");
>  		return -ENODEV;
> -- 
> 2.9.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 01/12] gpio: mockup: use devm_irq_alloc_descs()
  2017-03-04 16:23 ` [PATCH 01/12] gpio: mockup: use devm_irq_alloc_descs() Bartosz Golaszewski
@ 2017-03-08  8:21   ` Bamvor Zhang Jian
  2017-03-14 15:08   ` Linus Walleij
  1 sibling, 0 replies; 32+ messages in thread
From: Bamvor Zhang Jian @ 2017-03-08  8:21 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Alexandre Courbot, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Robert Jarzmik, linux-gpio,
	lkml, linux-omap, Thomas Gleixner, Marc Zyngier

On 4 March 2017 at 17:23, Bartosz Golaszewski <bgolaszewski@baylibre.com> wrote:
> Use the resource managed variant of irq_alloc_descs(). This allows us
> to remove gpio_mockup_remove().
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>

> ---
>  drivers/gpio/gpio-mockup.c | 16 +---------------
>  1 file changed, 1 insertion(+), 15 deletions(-)
>
> diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
> index 06dac72..37c2d69 100644
> --- a/drivers/gpio/gpio-mockup.c
> +++ b/drivers/gpio/gpio-mockup.c
> @@ -169,7 +169,7 @@ static int gpio_mockup_irqchip_setup(struct device *dev,
>         struct gpio_chip *gc = &chip->gc;
>         int irq_base, i;
>
> -       irq_base = irq_alloc_descs(-1, 0, gc->ngpio, 0);
> +       irq_base = devm_irq_alloc_descs(dev, -1, 0, gc->ngpio, 0);
>         if (irq_base < 0)
>                 return irq_base;
>
> @@ -373,25 +373,11 @@ static int gpio_mockup_probe(struct platform_device *pdev)
>         return 0;
>  }
>
> -static int gpio_mockup_remove(struct platform_device *pdev)
> -{
> -       struct gpio_mockup_chip *chips;
> -       int i;
> -
> -       chips = platform_get_drvdata(pdev);
> -
> -       for (i = 0; i < gpio_mockup_params_nr >> 1; i++)
> -               irq_free_descs(chips[i].gc.irq_base, chips[i].gc.ngpio);
> -
> -       return 0;
> -}
> -
>  static struct platform_driver gpio_mockup_driver = {
>         .driver = {
>                 .name = GPIO_MOCKUP_NAME,
>         },
>         .probe = gpio_mockup_probe,
> -       .remove = gpio_mockup_remove,
>  };
>
>  static struct platform_device *pdev;
> --
> 2.9.3
>

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

* Re: [PATCH 01/12] gpio: mockup: use devm_irq_alloc_descs()
  2017-03-04 16:23 ` [PATCH 01/12] gpio: mockup: use devm_irq_alloc_descs() Bartosz Golaszewski
  2017-03-08  8:21   ` Bamvor Zhang Jian
@ 2017-03-14 15:08   ` Linus Walleij
  1 sibling, 0 replies; 32+ messages in thread
From: Linus Walleij @ 2017-03-14 15:08 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Alexandre Courbot, Bamvor Jian Zhang, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Robert Jarzmik, linux-gpio,
	linux-kernel, Linux-OMAP, Thomas Gleixner, Marc Zyngier

On Sat, Mar 4, 2017 at 5:23 PM, Bartosz Golaszewski
<bgolaszewski@baylibre.com> wrote:

> Use the resource managed variant of irq_alloc_descs(). This allows us
> to remove gpio_mockup_remove().
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Patch applied with Bamvor's review tag.

Yours,
Linus Walleij

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

* Re: [PATCH 02/12] gpio: twl4030: use devm_irq_alloc_descs()
  2017-03-04 16:23 ` [PATCH 02/12] gpio: twl4030: " Bartosz Golaszewski
@ 2017-03-14 15:08   ` Linus Walleij
  0 siblings, 0 replies; 32+ messages in thread
From: Linus Walleij @ 2017-03-14 15:08 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Alexandre Courbot, Bamvor Jian Zhang, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Robert Jarzmik, linux-gpio,
	linux-kernel, Linux-OMAP, Thomas Gleixner, Marc Zyngier

On Sat, Mar 4, 2017 at 5:23 PM, Bartosz Golaszewski
<bgolaszewski@baylibre.com> wrote:

> This driver never frees the irq descriptors it allocates. Fix it by
> using a resource managed variant of irq_alloc_descs().
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Patch applied.

Yours,
Linus Walleij

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

* Re: [PATCH 03/12] gpio: omap: use devm_irq_alloc_descs()
  2017-03-04 16:23 ` [PATCH 03/12] gpio: omap: " Bartosz Golaszewski
  2017-03-06 16:50   ` Tony Lindgren
@ 2017-03-14 15:09   ` Linus Walleij
  1 sibling, 0 replies; 32+ messages in thread
From: Linus Walleij @ 2017-03-14 15:09 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Alexandre Courbot, Bamvor Jian Zhang, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Robert Jarzmik, linux-gpio,
	linux-kernel, Linux-OMAP, Thomas Gleixner, Marc Zyngier

On Sat, Mar 4, 2017 at 5:23 PM, Bartosz Golaszewski
<bgolaszewski@baylibre.com> wrote:

> This driver never frees the allocated interrupt descriptors. Fix it by
> using a resource managed variant of irq_alloc_descs().
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Patch applied.

Yours,
Linus Walleij

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

* Re: [PATCH 04/12] gpio: pch: use resource management for irqs
  2017-03-04 16:23 ` [PATCH 04/12] gpio: pch: use resource management for irqs Bartosz Golaszewski
@ 2017-03-14 15:10   ` Linus Walleij
  0 siblings, 0 replies; 32+ messages in thread
From: Linus Walleij @ 2017-03-14 15:10 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Alexandre Courbot, Bamvor Jian Zhang, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Robert Jarzmik, linux-gpio,
	linux-kernel, Linux-OMAP, Thomas Gleixner, Marc Zyngier

On Sat, Mar 4, 2017 at 5:23 PM, Bartosz Golaszewski
<bgolaszewski@baylibre.com> wrote:

> Use device resource managed variants of irq_alloc_descs() and
> request_irq() and remove the code manually freeing irq resources.
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Patch applied.

Yours,
Linus Walleij

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

* Re: [PATCH 05/12] gpio: ml-ioh: use resource management for irqs
  2017-03-04 16:23 ` [PATCH 05/12] gpio: ml-ioh: " Bartosz Golaszewski
@ 2017-03-14 15:11   ` Linus Walleij
  0 siblings, 0 replies; 32+ messages in thread
From: Linus Walleij @ 2017-03-14 15:11 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Alexandre Courbot, Bamvor Jian Zhang, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Robert Jarzmik, linux-gpio,
	linux-kernel, Linux-OMAP, Thomas Gleixner, Marc Zyngier

On Sat, Mar 4, 2017 at 5:23 PM, Bartosz Golaszewski
<bgolaszewski@baylibre.com> wrote:

> Use device resource managed variants of irq_alloc_descs() and
> request_irq() and remove the code manually freeing irq resources.
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Patch applied.

Yours,
Linus Walleij

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

* Re: [PATCH 06/12] gpio: xlp: use resource management for irqs
  2017-03-04 16:23 ` [PATCH 06/12] gpio: xlp: " Bartosz Golaszewski
@ 2017-03-14 15:11   ` Linus Walleij
  0 siblings, 0 replies; 32+ messages in thread
From: Linus Walleij @ 2017-03-14 15:11 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Alexandre Courbot, Bamvor Jian Zhang, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Robert Jarzmik, linux-gpio,
	linux-kernel, Linux-OMAP, Thomas Gleixner, Marc Zyngier

On Sat, Mar 4, 2017 at 5:23 PM, Bartosz Golaszewski
<bgolaszewski@baylibre.com> wrote:

> Use the resource managed variant of irq_alloc_descs() and remove the
> code manually freeing allocated interrupt descriptors.
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Patch applied.

Yours,
Linus Walleij

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

* Re: [PATCH 07/12] gpio: pxa: use devm_irq_alloc_descs()
  2017-03-04 16:23 ` [PATCH 07/12] gpio: pxa: use devm_irq_alloc_descs() Bartosz Golaszewski
  2017-03-04 20:31   ` Robert Jarzmik
@ 2017-03-14 15:12   ` Linus Walleij
  1 sibling, 0 replies; 32+ messages in thread
From: Linus Walleij @ 2017-03-14 15:12 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Alexandre Courbot, Bamvor Jian Zhang, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Robert Jarzmik, linux-gpio,
	linux-kernel, Linux-OMAP, Thomas Gleixner, Marc Zyngier

On Sat, Mar 4, 2017 at 5:23 PM, Bartosz Golaszewski
<bgolaszewski@baylibre.com> wrote:

> This driver never frees the interrupt descriptors it allocates. Fix
> it by using the resource managed version of irq_alloc_descs().
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Patch applied with Robert's ACK.

Yours,
Linus Walleij

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

* Re: [PATCH 08/12] gpio: davinci: use devm_irq_alloc_descs()
  2017-03-04 16:23 ` [PATCH 08/12] gpio: davinci: " Bartosz Golaszewski
  2017-03-06  4:59     ` Keerthy
@ 2017-03-14 15:13   ` Linus Walleij
  1 sibling, 0 replies; 32+ messages in thread
From: Linus Walleij @ 2017-03-14 15:13 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Alexandre Courbot, Bamvor Jian Zhang, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Robert Jarzmik, linux-gpio,
	linux-kernel, Linux-OMAP, Thomas Gleixner, Marc Zyngier

On Sat, Mar 4, 2017 at 5:23 PM, Bartosz Golaszewski
<bgolaszewski@baylibre.com> wrote:

> This driver never frees the interrupt descriptors it allocates. Fix
> it by using the resource managed version of irq_alloc_descs().
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Patch applied with Keerty's ACK.

Yours,
Linus Walleij

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

* Re: [PATCH 09/12] gpio: sodaville: use resource management for irqs
  2017-03-04 16:23 ` [PATCH 09/12] gpio: sodaville: use resource management for irqs Bartosz Golaszewski
@ 2017-03-14 15:14   ` Linus Walleij
  0 siblings, 0 replies; 32+ messages in thread
From: Linus Walleij @ 2017-03-14 15:14 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Alexandre Courbot, Bamvor Jian Zhang, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Robert Jarzmik, linux-gpio,
	linux-kernel, Linux-OMAP, Thomas Gleixner, Marc Zyngier

On Sat, Mar 4, 2017 at 5:23 PM, Bartosz Golaszewski
<bgolaszewski@baylibre.com> wrote:

> Use device resource managed variants of irq_alloc_descs() and
> request_irq() and remove the code manually freeing irq resources.
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Patch applied.

Yours,
Linus Walleij

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

* Re: [PATCH 10/12] gpio: mxc: use devm_irq_alloc_descs()
  2017-03-04 16:23 ` [PATCH 10/12] gpio: mxc: use devm_irq_alloc_descs() Bartosz Golaszewski
@ 2017-03-14 15:15   ` Linus Walleij
  0 siblings, 0 replies; 32+ messages in thread
From: Linus Walleij @ 2017-03-14 15:15 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Alexandre Courbot, Bamvor Jian Zhang, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Robert Jarzmik, linux-gpio,
	linux-kernel, Linux-OMAP, Thomas Gleixner, Marc Zyngier

On Sat, Mar 4, 2017 at 5:23 PM, Bartosz Golaszewski
<bgolaszewski@baylibre.com> wrote:

> This driver never frees the interrupt descriptors it allocates. Fix
> it by using the resource managed version of irq_alloc_descs().
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Patch applied.

Yours,
Linus Walleij

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

* Re: [PATCH 11/12] gpio: mxs: use devm_irq_alloc_descs()
  2017-03-04 16:23 ` [PATCH 11/12] gpio: mxs: " Bartosz Golaszewski
@ 2017-03-14 15:16   ` Linus Walleij
  0 siblings, 0 replies; 32+ messages in thread
From: Linus Walleij @ 2017-03-14 15:16 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Alexandre Courbot, Bamvor Jian Zhang, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Robert Jarzmik, linux-gpio,
	linux-kernel, Linux-OMAP, Thomas Gleixner, Marc Zyngier

On Sat, Mar 4, 2017 at 5:23 PM, Bartosz Golaszewski
<bgolaszewski@baylibre.com> wrote:

> This driver never frees the interrupt descriptors it allocates. Fix
> it by using the resource managed version of irq_alloc_descs().
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Patch applied.

Yours,
Linus Walleij

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

* Re: [PATCH 12/12] gpio: sta2x11: use resource management for irqs
  2017-03-04 16:23 ` [PATCH 12/12] gpio: sta2x11: use resource management for irqs Bartosz Golaszewski
@ 2017-03-14 15:16   ` Linus Walleij
  0 siblings, 0 replies; 32+ messages in thread
From: Linus Walleij @ 2017-03-14 15:16 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Alexandre Courbot, Bamvor Jian Zhang, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Robert Jarzmik, linux-gpio,
	linux-kernel, Linux-OMAP, Thomas Gleixner, Marc Zyngier

On Sat, Mar 4, 2017 at 5:23 PM, Bartosz Golaszewski
<bgolaszewski@baylibre.com> wrote:

> Use device resource managed variants of irq_alloc_descs() and
> request_irq() and remove the code manually freeing irq resources.
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Patch applied.

Yours,
Linus Walleij

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

* Re: [PATCH 00/12] gpio: use resource management for irq descriptors
  2017-03-04 16:23 [PATCH 00/12] gpio: use resource management for irq descriptors Bartosz Golaszewski
                   ` (11 preceding siblings ...)
  2017-03-04 16:23 ` [PATCH 12/12] gpio: sta2x11: use resource management for irqs Bartosz Golaszewski
@ 2017-03-14 15:18 ` Linus Walleij
  2017-03-14 15:45   ` Bartosz Golaszewski
  12 siblings, 1 reply; 32+ messages in thread
From: Linus Walleij @ 2017-03-14 15:18 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Alexandre Courbot, Bamvor Jian Zhang, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Robert Jarzmik, linux-gpio,
	linux-kernel, Linux-OMAP, Thomas Gleixner, Marc Zyngier

On Sat, Mar 4, 2017 at 5:23 PM, Bartosz Golaszewski
<bgolaszewski@baylibre.com> wrote:

> The following series uses the recently introduced set of
> devm_irq_alloc_desc*() helpers in the GPIO drivers.
>
> While we're at it: if the modified drivers called request_irq(), it
> was changed to devm_request_irq() too.
>
> Some drivers correctly clean up resources (e.g. gpio-mockup,
> gpio-pch) - for them this change leads to an actual code shrink.
>
> Other drivers are meant to be built-in and the devices they control
> are never removed (e.g. gpio-pxa, gpio-davinci), so they deliberately
> omit the cleanup. Still: in case something changes it's better to free
> the resources - especially since these drivers already use other
> devm_* routines like devm_kzalloc() etc.
>
> The last group of drivers are the ones which can be compiled as
> modules, but leak resources unintentionally (e.g. gpio-twl4030,
> gpio-omap). This change fixes the interrupt descriptor leaks, but some
> drivers will require additional work since they still don't release
> other resources.
>
> The following drivers were tested: gpio-mockup, gpio-omap
> and gpio-davinci. The rest was compile-tested only.
>
> Bartosz Golaszewski (12):
>   gpio: mockup: use devm_irq_alloc_descs()
>   gpio: twl4030: use devm_irq_alloc_descs()
>   gpio: omap: use devm_irq_alloc_descs()
>   gpio: pch: use resource management for irqs
>   gpio: ml-ioh: use resource management for irqs
>   gpio: xlp: use resource management for irqs
>   gpio: pxa: use devm_irq_alloc_descs()
>   gpio: davinci: use devm_irq_alloc_descs()
>   gpio: sodaville: use resource management for irqs
>   gpio: mxc: use devm_irq_alloc_descs()
>   gpio: mxs: use devm_irq_alloc_descs()
>   gpio: sta2x11: use resource management for irqs

Excellent series, applied all and pushing to the build servers for
testing.

Interested in the job to go over to drivers/pinctrl and check if we
have some dangling descs there if this works out?

Yours,
Linus Walleij

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

* Re: [PATCH 00/12] gpio: use resource management for irq descriptors
  2017-03-14 15:18 ` [PATCH 00/12] gpio: use resource management for irq descriptors Linus Walleij
@ 2017-03-14 15:45   ` Bartosz Golaszewski
  0 siblings, 0 replies; 32+ messages in thread
From: Bartosz Golaszewski @ 2017-03-14 15:45 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Alexandre Courbot, Bamvor Jian Zhang, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Robert Jarzmik, linux-gpio,
	linux-kernel, Linux-OMAP, Thomas Gleixner, Marc Zyngier

2017-03-14 16:18 GMT+01:00 Linus Walleij <linus.walleij@linaro.org>:
>
> Excellent series, applied all and pushing to the build servers for
> testing.
>

Thanks!

> Interested in the job to go over to drivers/pinctrl and check if we
> have some dangling descs there if this works out?
>

If time permits, I will be improving the resource management for
interrupts (generic-chip, domains etc.), so I may end up in pinctrl at
some point.

Best regards,
Bartosz Golaszewski

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

end of thread, other threads:[~2017-03-14 15:45 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-04 16:23 [PATCH 00/12] gpio: use resource management for irq descriptors Bartosz Golaszewski
2017-03-04 16:23 ` [PATCH 01/12] gpio: mockup: use devm_irq_alloc_descs() Bartosz Golaszewski
2017-03-08  8:21   ` Bamvor Zhang Jian
2017-03-14 15:08   ` Linus Walleij
2017-03-04 16:23 ` [PATCH 02/12] gpio: twl4030: " Bartosz Golaszewski
2017-03-14 15:08   ` Linus Walleij
2017-03-04 16:23 ` [PATCH 03/12] gpio: omap: " Bartosz Golaszewski
2017-03-06 16:50   ` Tony Lindgren
2017-03-14 15:09   ` Linus Walleij
2017-03-04 16:23 ` [PATCH 04/12] gpio: pch: use resource management for irqs Bartosz Golaszewski
2017-03-14 15:10   ` Linus Walleij
2017-03-04 16:23 ` [PATCH 05/12] gpio: ml-ioh: " Bartosz Golaszewski
2017-03-14 15:11   ` Linus Walleij
2017-03-04 16:23 ` [PATCH 06/12] gpio: xlp: " Bartosz Golaszewski
2017-03-14 15:11   ` Linus Walleij
2017-03-04 16:23 ` [PATCH 07/12] gpio: pxa: use devm_irq_alloc_descs() Bartosz Golaszewski
2017-03-04 20:31   ` Robert Jarzmik
2017-03-14 15:12   ` Linus Walleij
2017-03-04 16:23 ` [PATCH 08/12] gpio: davinci: " Bartosz Golaszewski
2017-03-06  4:59   ` Keerthy
2017-03-06  4:59     ` Keerthy
2017-03-14 15:13   ` Linus Walleij
2017-03-04 16:23 ` [PATCH 09/12] gpio: sodaville: use resource management for irqs Bartosz Golaszewski
2017-03-14 15:14   ` Linus Walleij
2017-03-04 16:23 ` [PATCH 10/12] gpio: mxc: use devm_irq_alloc_descs() Bartosz Golaszewski
2017-03-14 15:15   ` Linus Walleij
2017-03-04 16:23 ` [PATCH 11/12] gpio: mxs: " Bartosz Golaszewski
2017-03-14 15:16   ` Linus Walleij
2017-03-04 16:23 ` [PATCH 12/12] gpio: sta2x11: use resource management for irqs Bartosz Golaszewski
2017-03-14 15:16   ` Linus Walleij
2017-03-14 15:18 ` [PATCH 00/12] gpio: use resource management for irq descriptors Linus Walleij
2017-03-14 15:45   ` Bartosz Golaszewski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.