浏览代码

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>
Masahiro Yamada 9 年之前
父节点
当前提交
1020dfd15b
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      drivers/gpio/gpiolib-of.c

+ 4 - 1
drivers/gpio/gpiolib-of.c

@@ -155,7 +155,7 @@ static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
 	if (ret)
 	if (ret)
 		return ERR_PTR(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);
 		return ERR_PTR(-EINVAL);
 
 
 	gpiospec.np = chip_np;
 	gpiospec.np = chip_np;
@@ -486,6 +486,9 @@ int of_gpiochip_add(struct gpio_chip *chip)
 		chip->of_xlate = of_gpio_simple_xlate;
 		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);
 	status = of_gpiochip_add_pin_range(chip);
 	if (status)
 	if (status)
 		return status;
 		return status;