linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: Check if base is positive before calling gpio_is_valid()
@ 2014-11-17 14:31 Geert Uytterhoeven
  2014-11-18  3:06 ` Alexandre Courbot
  0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2014-11-17 14:31 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot
  Cc: linux-gpio, linux-kernel, Geert Uytterhoeven

It doesn't make much sense to make some (possible expensive) calls to
gpio_is_valid() first, and to ignore the result if the base number is
negative. Check for a positive base number first.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/gpio/gpiolib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 2e3d66adc6880950..bdf2020e103c7bc0 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -227,8 +227,8 @@ int gpiochip_add(struct gpio_chip *chip)
 	unsigned	id;
 	int		base = chip->base;
 
-	if ((!gpio_is_valid(base) || !gpio_is_valid(base + chip->ngpio - 1))
-			&& base >= 0) {
+	if (base >= 0 &&
+	    (!gpio_is_valid(base) || !gpio_is_valid(base + chip->ngpio - 1))) {
 		status = -EINVAL;
 		goto fail;
 	}
-- 
1.9.1


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

* Re: [PATCH] gpio: Check if base is positive before calling gpio_is_valid()
  2014-11-17 14:31 [PATCH] gpio: Check if base is positive before calling gpio_is_valid() Geert Uytterhoeven
@ 2014-11-18  3:06 ` Alexandre Courbot
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Courbot @ 2014-11-18  3:06 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linus Walleij, linux-gpio@vger.kernel.org,
	Linux Kernel Mailing List

On Mon, Nov 17, 2014 at 11:31 PM, Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
> It doesn't make much sense to make some (possible expensive) calls to
> gpio_is_valid() first, and to ignore the result if the base number is
> negative. Check for a positive base number first.

Sure.

Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>

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

end of thread, other threads:[~2014-11-18  3:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-17 14:31 [PATCH] gpio: Check if base is positive before calling gpio_is_valid() Geert Uytterhoeven
2014-11-18  3:06 ` Alexandre Courbot

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