diff mbox

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

Message ID 1455932887.31674.0.camel@ingics.com
State New
Headers show

Commit Message

Axel Lin Feb. 20, 2016, 1:48 a.m. UTC
Move the code checking valid gpio count to cover both DT and non-DT cases.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/gpio/gpio-ath79.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Alban Feb. 20, 2016, 6:11 p.m. UTC | #1
On Sat, 20 Feb 2016 09:48:07 +0800
Axel Lin <axel.lin@ingics.com> wrote:

> 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: Aban Bedel <albeu@free.fr>

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

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Linus Walleij Feb. 25, 2016, 9:10 a.m. UTC | #2
On Sat, Feb 20, 2016 at 2:48 AM, Axel Lin <axel.lin@ingics.com> wrote:

> Move the code checking valid gpio count to cover both DT and non-DT cases.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>

Patch applied with Alban's ACK.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/gpio/gpio-ath79.c b/drivers/gpio/gpio-ath79.c
index 018ea9d..c4f4cdd 100644
--- a/drivers/gpio/gpio-ath79.c
+++ b/drivers/gpio/gpio-ath79.c
@@ -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));