提交 86256d1f 编写于 作者: G Geert Uytterhoeven 提交者: Linus Walleij

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: NGeert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: NAlexandre Courbot <acourbot@nvidia.com>
Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
上级 a231b88c
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册