summaryrefslogtreecommitdiff
path: root/drivers/gpio/gpiolib-of.c
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2016-06-14 19:07:05 +0900
committerLinus Walleij <linus.walleij@linaro.org>2016-06-23 11:07:11 +0200
commit1020dfd15b2363bf652851c490a27a550070346e (patch)
treeb88e6f4fc70825e95c495318f7767f79710ae1d3 /drivers/gpio/gpiolib-of.c
parentbe715343011b80a8da71ff978b50981984f037b9 (diff)
gpio: of: move chip->of_gpio_n_cells checking to of_gpiochip_add()
Do this sanity check only once when the gpio_chip is added rather than every time gpio-hog is handled. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib-of.c')
-rw-r--r--drivers/gpio/gpiolib-of.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 37a3221d67dc..a68e42dcce0a 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -155,7 +155,7 @@ static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
if (ret)
return ERR_PTR(ret);
- if (tmp > MAX_PHANDLE_ARGS || tmp != chip->of_gpio_n_cells)
+ if (tmp != chip->of_gpio_n_cells)
return ERR_PTR(-EINVAL);
gpiospec.np = chip_np;
@@ -486,6 +486,9 @@ int of_gpiochip_add(struct gpio_chip *chip)
chip->of_xlate = of_gpio_simple_xlate;
}
+ if (chip->of_gpio_n_cells > MAX_PHANDLE_ARGS)
+ return -EINVAL;
+
status = of_gpiochip_add_pin_range(chip);
if (status)
return status;