Skip to contentSkip to conversation

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

PATCH In review Axel Lin 3 participants 3 messages Feb 20, 2016 – Feb 25, 2016

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 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.

---
 drivers/gpio/gpio-ath79.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpio/gpio-ath79.c +5 -4
index 018ea9d..c4f4cdd 100644
@@ -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));
Signature · 1 line
2.1.4
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · On Sat, 20 Feb 2016 09:48:07 +0800 Axel Lin <[email protected]> wrote:

Move the code checking valid gpio count to cover both DT and non-DT cases.

Quoted 31 lines
---
 drivers/gpio/gpio-ath79.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpio/gpio-ath79.c +5 -4
index 018ea9d..c4f4cdd 100644
@@ -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));