linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpiolib: Fix inverted check in gpiochip_remove()
@ 2020-03-02  8:24 Geert Uytterhoeven
  2020-03-02 10:53 ` Andy Shevchenko
  2020-03-03 12:34 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2020-03-02  8:24 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko
  Cc: linux-gpio, linux-kernel, Geert Uytterhoeven

The optimization to check for requested lines actually optimized for the
uncomon error case, where one of the GPIO lines is still in use.
Hence the error message must be printed when the loop is terminated
early, not when it went through all available GPIO lines.

Fixes: 869233f81337bfb3 ("gpiolib: Optimize gpiochip_remove() when check for requested line")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Noticed by review, tested by creating and destroying an otherwise unused
GPIO aggregator, which triggers:

    gpio gpiochip8: REMOVING GPIOCHIP WITH GPIOS STILL REQUESTED
---
 drivers/gpio/gpiolib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 4e78bdc2739693c3..6180cf84fab7ce5e 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1823,7 +1823,7 @@ void gpiochip_remove(struct gpio_chip *chip)
 	}
 	spin_unlock_irqrestore(&gpio_lock, flags);
 
-	if (i == gdev->ngpio)
+	if (i != gdev->ngpio)
 		dev_crit(&gdev->dev,
 			 "REMOVING GPIOCHIP WITH GPIOS STILL REQUESTED\n");
 
-- 
2.17.1


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

* Re: [PATCH] gpiolib: Fix inverted check in gpiochip_remove()
  2020-03-02  8:24 [PATCH] gpiolib: Fix inverted check in gpiochip_remove() Geert Uytterhoeven
@ 2020-03-02 10:53 ` Andy Shevchenko
  2020-03-03 12:34 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2020-03-02 10:53 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linus Walleij, Bartosz Golaszewski, linux-gpio, linux-kernel

On Mon, Mar 02, 2020 at 09:24:48AM +0100, Geert Uytterhoeven wrote:
> The optimization to check for requested lines actually optimized for the
> uncomon error case, where one of the GPIO lines is still in use.
> Hence the error message must be printed when the loop is terminated
> early, not when it went through all available GPIO lines.
> 
> Fixes: 869233f81337bfb3 ("gpiolib: Optimize gpiochip_remove() when check for requested line")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> Noticed by review, tested by creating and destroying an otherwise unused
> GPIO aggregator, which triggers:
> 
>     gpio gpiochip8: REMOVING GPIOCHIP WITH GPIOS STILL REQUESTED

Thank you!

Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Linus, see below.

> ---
>  drivers/gpio/gpiolib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 4e78bdc2739693c3..6180cf84fab7ce5e 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -1823,7 +1823,7 @@ void gpiochip_remove(struct gpio_chip *chip)
>  	}
>  	spin_unlock_irqrestore(&gpio_lock, flags);
>  
> -	if (i == gdev->ngpio)
> +	if (i != gdev->ngpio)

I prefer more explicit <.

I had sent a patch (before I noticed this), so it's up to Linus which one to choose.

>  		dev_crit(&gdev->dev,
>  			 "REMOVING GPIOCHIP WITH GPIOS STILL REQUESTED\n");
>  
> -- 
> 2.17.1
> 

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH] gpiolib: Fix inverted check in gpiochip_remove()
  2020-03-02  8:24 [PATCH] gpiolib: Fix inverted check in gpiochip_remove() Geert Uytterhoeven
  2020-03-02 10:53 ` Andy Shevchenko
@ 2020-03-03 12:34 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2020-03-03 12:34 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Bartosz Golaszewski, Andy Shevchenko, open list:GPIO SUBSYSTEM,
	linux-kernel

On Mon, Mar 2, 2020 at 9:24 AM Geert Uytterhoeven
<geert+renesas@glider.be> wrote:

> The optimization to check for requested lines actually optimized for the
> uncomon error case, where one of the GPIO lines is still in use.
> Hence the error message must be printed when the loop is terminated
> early, not when it went through all available GPIO lines.
>
> Fixes: 869233f81337bfb3 ("gpiolib: Optimize gpiochip_remove() when check for requested line")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Patch applied with Andy's ACK.

Yours,
Linus Walleij

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

end of thread, other threads:[~2020-03-03 12:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-02  8:24 [PATCH] gpiolib: Fix inverted check in gpiochip_remove() Geert Uytterhoeven
2020-03-02 10:53 ` Andy Shevchenko
2020-03-03 12:34 ` Linus Walleij

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