diff options
author | Geert Uytterhoeven <geert+renesas@glider.be> | 2014-11-17 09:31:59 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2014-11-27 09:11:18 -0500 |
commit | 86256d1fceff058d5afea6dfcc8a2eac18a71e95 (patch) | |
tree | dd17bc67c3fcdb02dceb710dafffaad6218c119d /drivers/gpio/gpiolib.c | |
parent | a231b88cfc3df120d3882c0be9499970af87f305 (diff) |
gpio: Check if base is positive before calling gpio_is_valid()
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>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r-- | drivers/gpio/gpiolib.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index eb739a51e774..12d981a5be66 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -227,8 +227,8 @@ int gpiochip_add(struct gpio_chip *chip) | |||
227 | unsigned id; | 227 | unsigned id; |
228 | int base = chip->base; | 228 | int base = chip->base; |
229 | 229 | ||
230 | if ((!gpio_is_valid(base) || !gpio_is_valid(base + chip->ngpio - 1)) | 230 | if (base >= 0 && |
231 | && base >= 0) { | 231 | (!gpio_is_valid(base) || !gpio_is_valid(base + chip->ngpio - 1))) { |
232 | status = -EINVAL; | 232 | status = -EINVAL; |
233 | goto fail; | 233 | goto fail; |
234 | } | 234 | } |