gpio: ath79: Check valid gpio count for both DT and non-DT cases
authorAxel Lin <axel.lin@ingics.com>
Sat, 20 Feb 2016 01:48:07 +0000 (09:48 +0800)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 25 Feb 2016 09:09:59 +0000 (10:09 +0100)
Move the code checking valid gpio count to cover both DT and non-DT cases.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Alban Bedel <albeu@free.fr>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-ath79.c

index 018ea9d33b54142b836c49148c017504828ccd2d..c4f4cddc7c1a42e52f2f7f80926878e084ded70e 100644 (file)
@@ -240,10 +240,6 @@ static int ath79_gpio_probe(struct platform_device *pdev)
                        dev_err(&pdev->dev, "ngpios property is not valid\n");
                        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");
        } else if (pdata) {
                ath79_gpio_count = pdata->ngpios;
@@ -253,6 +249,11 @@ static int ath79_gpio_probe(struct platform_device *pdev)
                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);
        ctrl->base = devm_ioremap_nocache(
                &pdev->dev, res->start, resource_size(res));