diff mbox series

[v1] gpio: pca953x: Fix GPIO resource leak on Intel Galileo Gen 2

Message ID 20200618114906.79346-1-andriy.shevchenko@linux.intel.com
State New
Headers show
Series [v1] gpio: pca953x: Fix GPIO resource leak on Intel Galileo Gen 2 | expand

Commit Message

Andy Shevchenko June 18, 2020, 11:49 a.m. UTC
When adding a quirk for IRQ on Intel Galileo Gen 2 the commit ba8c90c61847
("gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2")
missed GPIO resource release. We can safely do this in the same quirk, since
IRQ will be locked by GPIO framework when requested and unlocked on freeing.

Fixes: ba8c90c61847 ("gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/gpio/gpio-pca953x.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Mika Westerberg June 18, 2020, 11:57 a.m. UTC | #1
On Thu, Jun 18, 2020 at 02:49:06PM +0300, Andy Shevchenko wrote:
> When adding a quirk for IRQ on Intel Galileo Gen 2 the commit ba8c90c61847
> ("gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2")
> missed GPIO resource release. We can safely do this in the same quirk, since
> IRQ will be locked by GPIO framework when requested and unlocked on freeing.
> 
> Fixes: ba8c90c61847 ("gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Linus Walleij June 20, 2020, 9:31 p.m. UTC | #2
On Thu, Jun 18, 2020 at 1:49 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> When adding a quirk for IRQ on Intel Galileo Gen 2 the commit ba8c90c61847
> ("gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2")
> missed GPIO resource release. We can safely do this in the same quirk, since
> IRQ will be locked by GPIO framework when requested and unlocked on freeing.
>
> Fixes: ba8c90c61847 ("gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>

This seems to go on top of what Bartosz applied so I expect him to pick
it up!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Andy Shevchenko June 21, 2020, 8:23 a.m. UTC | #3
On Sun, Jun 21, 2020 at 12:33 AM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> On Thu, Jun 18, 2020 at 1:49 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
>
> > When adding a quirk for IRQ on Intel Galileo Gen 2 the commit ba8c90c61847
> > ("gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2")
> > missed GPIO resource release. We can safely do this in the same quirk, since
> > IRQ will be locked by GPIO framework when requested and unlocked on freeing.
> >
> > Fixes: ba8c90c61847 ("gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2")
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
>
> This seems to go on top of what Bartosz applied so I expect him to pick
> it up!

Yes, that's what is expected.

> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Thanks!
Bartosz Golaszewski June 22, 2020, 4:52 p.m. UTC | #4
niedz., 21 cze 2020 o 10:23 Andy Shevchenko
<andy.shevchenko@gmail.com> napisaƂ(a):
>
> On Sun, Jun 21, 2020 at 12:33 AM Linus Walleij <linus.walleij@linaro.org> wrote:
> >
> > On Thu, Jun 18, 2020 at 1:49 PM Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
> >
> > > When adding a quirk for IRQ on Intel Galileo Gen 2 the commit ba8c90c61847
> > > ("gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2")
> > > missed GPIO resource release. We can safely do this in the same quirk, since
> > > IRQ will be locked by GPIO framework when requested and unlocked on freeing.
> > >
> > > Fixes: ba8c90c61847 ("gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2")
> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > > Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> >
> > This seems to go on top of what Bartosz applied so I expect him to pick
> > it up!
>
> Yes, that's what is expected.
>
> > Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
>
> Thanks!
>
> --
> With Best Regards,
> Andy Shevchenko

Applied for fixes. I'll send a PR to Linus later this week.

Bart
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index cea22fcc2a24..9c90cf3aac5a 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -177,7 +177,12 @@  static int pca953x_acpi_get_irq(struct device *dev)
 	if (ret)
 		return ret;
 
-	return gpio_to_irq(pin);
+	ret = gpio_to_irq(pin);
+
+	/* When pin is used as an IRQ, no need to keep it requested */
+	gpio_free(pin);
+
+	return ret;
 }
 #endif