Commit f0d3c72c authored by Axel Lin's avatar Axel Lin Committed by Linus Walleij

gpio: ath79: Check valid gpio count for both DT and non-DT cases

Move the code checking valid gpio count to cover both DT and non-DT cases.
Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Acked-by: default avatarAlban Bedel <albeu@free.fr>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 40c8eaba
...@@ -240,10 +240,6 @@ static int ath79_gpio_probe(struct platform_device *pdev) ...@@ -240,10 +240,6 @@ static int ath79_gpio_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "ngpios property is not valid\n"); dev_err(&pdev->dev, "ngpios property is not valid\n");
return err; return err;
} }
if (ath79_gpio_count >= 32) {
dev_err(&pdev->dev, "ngpios must be less than 32\n");
return -EINVAL;
}
oe_inverted = of_device_is_compatible(np, "qca,ar9340-gpio"); oe_inverted = of_device_is_compatible(np, "qca,ar9340-gpio");
} else if (pdata) { } else if (pdata) {
ath79_gpio_count = pdata->ngpios; ath79_gpio_count = pdata->ngpios;
...@@ -253,6 +249,11 @@ static int ath79_gpio_probe(struct platform_device *pdev) ...@@ -253,6 +249,11 @@ static int ath79_gpio_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
if (ath79_gpio_count >= 32) {
dev_err(&pdev->dev, "ngpios must be less than 32\n");
return -EINVAL;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
ctrl->base = devm_ioremap_nocache( ctrl->base = devm_ioremap_nocache(
&pdev->dev, res->start, resource_size(res)); &pdev->dev, res->start, resource_size(res));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment