[PATCH v2] gpio: ath79: Add missing check for platform_get_irq

Jiasheng Jiang posted 1 patch 2 years, 8 months ago
There is a newer version of this series
drivers/gpio/gpio-ath79.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH v2] gpio: ath79: Add missing check for platform_get_irq
Posted by Jiasheng Jiang 2 years, 8 months ago
Add the missing check for platform_get_irq and return error code
if it fails.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
Changelog:

v1 -> v2:

1. Return "girq->parents[0]" instead of "-ENODEV".
---
 drivers/gpio/gpio-ath79.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpio/gpio-ath79.c b/drivers/gpio/gpio-ath79.c
index aa0a954b8392..31ce2d5c6ba0 100644
--- a/drivers/gpio/gpio-ath79.c
+++ b/drivers/gpio/gpio-ath79.c
@@ -286,6 +286,8 @@ static int ath79_gpio_probe(struct platform_device *pdev)
 		if (!girq->parents)
 			return -ENOMEM;
 		girq->parents[0] = platform_get_irq(pdev, 0);
+		if (girq->parents[0] < 0)
+			return girq->parents[0];
 		girq->default_type = IRQ_TYPE_NONE;
 		girq->handler = handle_simple_irq;
 	}
-- 
2.25.1
Re: [PATCH v2] gpio: ath79: Add missing check for platform_get_irq
Posted by Andy Shevchenko 2 years, 8 months ago
On Fri, Jun 2, 2023 at 10:33 AM Jiasheng Jiang <jiasheng@iscas.ac.cn> wrote:
>
> Add the missing check for platform_get_irq and return error code
> if it fails.

The template for function references is func().
Otherwise looks fine to me
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
> Changelog:
>
> v1 -> v2:
>
> 1. Return "girq->parents[0]" instead of "-ENODEV".
> ---
>  drivers/gpio/gpio-ath79.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpio/gpio-ath79.c b/drivers/gpio/gpio-ath79.c
> index aa0a954b8392..31ce2d5c6ba0 100644
> --- a/drivers/gpio/gpio-ath79.c
> +++ b/drivers/gpio/gpio-ath79.c
> @@ -286,6 +286,8 @@ static int ath79_gpio_probe(struct platform_device *pdev)
>                 if (!girq->parents)
>                         return -ENOMEM;
>                 girq->parents[0] = platform_get_irq(pdev, 0);
> +               if (girq->parents[0] < 0)
> +                       return girq->parents[0];
>                 girq->default_type = IRQ_TYPE_NONE;
>                 girq->handler = handle_simple_irq;
>         }
> --
> 2.25.1
>


-- 
With Best Regards,
Andy Shevchenko