diff mbox series

gpio: xgs-iproc: fix parsing of ngpios property

Message ID 20211014123342.174711-1-jonas.gorski@gmail.com (mailing list archive)
State New, archived
Headers show
Series gpio: xgs-iproc: fix parsing of ngpios property | expand

Commit Message

Jonas Gorski Oct. 14, 2021, 12:33 p.m. UTC
of_property_read_u32 returns 0 on success, not true, so we need to
invert the check to actually take over the provided ngpio value.

Fixes: 6a41b6c5fc20 ("gpio: Add xgs-iproc driver")
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
This is based on
git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git,
which is the tree for GPIO according to MAINTAINERS, but hasn't been
updated since ~5.11 - is this still the correct tree?

It doesn't matter much for this patch though, the driver is virtually
untouched since then.

 drivers/gpio/gpio-xgs-iproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Chris Packham Oct. 17, 2021, 11:21 p.m. UTC | #1
On 15/10/21 1:33 am, Jonas Gorski wrote:
> of_property_read_u32 returns 0 on success, not true, so we need to
> invert the check to actually take over the provided ngpio value.
>
> Fixes: 6a41b6c5fc20 ("gpio: Add xgs-iproc driver")
> Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>

Hmm I must have copied some error handling code and failed to invert the 
condition when I made the property optional.

Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>

> ---
> This is based on
> git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git,
> which is the tree for GPIO according to MAINTAINERS, but hasn't been
> updated since ~5.11 - is this still the correct tree?
>
> It doesn't matter much for this patch though, the driver is virtually
> untouched since then.
>
>   drivers/gpio/gpio-xgs-iproc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-xgs-iproc.c b/drivers/gpio/gpio-xgs-iproc.c
> index ad5489a65d54..dd40277b9d06 100644
> --- a/drivers/gpio/gpio-xgs-iproc.c
> +++ b/drivers/gpio/gpio-xgs-iproc.c
> @@ -224,7 +224,7 @@ static int iproc_gpio_probe(struct platform_device *pdev)
>   	}
>   
>   	chip->gc.label = dev_name(dev);
> -	if (of_property_read_u32(dn, "ngpios", &num_gpios))
> +	if (!of_property_read_u32(dn, "ngpios", &num_gpios))
>   		chip->gc.ngpio = num_gpios;
>   
>   	irq = platform_get_irq(pdev, 0);
Florian Fainelli Oct. 22, 2021, 7:29 p.m. UTC | #2
On 10/14/21 5:33 AM, Jonas Gorski wrote:
> of_property_read_u32 returns 0 on success, not true, so we need to
> invert the check to actually take over the provided ngpio value.
> 
> Fixes: 6a41b6c5fc20 ("gpio: Add xgs-iproc driver")
> Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Linus Walleij Oct. 24, 2021, 11:49 p.m. UTC | #3
On Thu, Oct 14, 2021 at 2:33 PM Jonas Gorski <jonas.gorski@gmail.com> wrote:

> of_property_read_u32 returns 0 on success, not true, so we need to
> invert the check to actually take over the provided ngpio value.
>
> Fixes: 6a41b6c5fc20 ("gpio: Add xgs-iproc driver")
> Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Bartosz Golaszewski Oct. 25, 2021, 8:12 a.m. UTC | #4
On Thu, Oct 14, 2021 at 2:33 PM Jonas Gorski <jonas.gorski@gmail.com> wrote:
>
> of_property_read_u32 returns 0 on success, not true, so we need to
> invert the check to actually take over the provided ngpio value.
>
> Fixes: 6a41b6c5fc20 ("gpio: Add xgs-iproc driver")
> Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
> ---
> This is based on
> git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git,
> which is the tree for GPIO according to MAINTAINERS, but hasn't been
> updated since ~5.11 - is this still the correct tree?
>
> It doesn't matter much for this patch though, the driver is virtually
> untouched since then.
>
>  drivers/gpio/gpio-xgs-iproc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-xgs-iproc.c b/drivers/gpio/gpio-xgs-iproc.c
> index ad5489a65d54..dd40277b9d06 100644
> --- a/drivers/gpio/gpio-xgs-iproc.c
> +++ b/drivers/gpio/gpio-xgs-iproc.c
> @@ -224,7 +224,7 @@ static int iproc_gpio_probe(struct platform_device *pdev)
>         }
>
>         chip->gc.label = dev_name(dev);
> -       if (of_property_read_u32(dn, "ngpios", &num_gpios))
> +       if (!of_property_read_u32(dn, "ngpios", &num_gpios))
>                 chip->gc.ngpio = num_gpios;
>
>         irq = platform_get_irq(pdev, 0);
> --
> 2.33.0
>

Queued for fixes.

Bart
Andy Shevchenko Oct. 31, 2021, 1:24 p.m. UTC | #5
On Thu, Oct 14, 2021 at 3:48 PM Jonas Gorski <jonas.gorski@gmail.com> wrote:
>
> of_property_read_u32 returns 0 on success, not true, so we need to
> invert the check to actually take over the provided ngpio value.

> -       if (of_property_read_u32(dn, "ngpios", &num_gpios))
> +       if (!of_property_read_u32(dn, "ngpios", &num_gpios))
>                 chip->gc.ngpio = num_gpios;

Just a side note: I'm wondering how many of such we have in the
drivers and why we can't simply do it under the OF GPIO library's hood
for everybody.
Bartosz Golaszewski Nov. 2, 2021, 1:09 p.m. UTC | #6
On Sun, Oct 31, 2021 at 2:25 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Thu, Oct 14, 2021 at 3:48 PM Jonas Gorski <jonas.gorski@gmail.com> wrote:
> >
> > of_property_read_u32 returns 0 on success, not true, so we need to
> > invert the check to actually take over the provided ngpio value.
>
> > -       if (of_property_read_u32(dn, "ngpios", &num_gpios))
> > +       if (!of_property_read_u32(dn, "ngpios", &num_gpios))
> >                 chip->gc.ngpio = num_gpios;
>
> Just a side note: I'm wondering how many of such we have in the
> drivers and why we can't simply do it under the OF GPIO library's hood
> for everybody.
>
> --
> With Best Regards,
> Andy Shevchenko

Looks like we have 17, so yes, definitely a candidate for pulling into
the GPIO core.

Bart
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-xgs-iproc.c b/drivers/gpio/gpio-xgs-iproc.c
index ad5489a65d54..dd40277b9d06 100644
--- a/drivers/gpio/gpio-xgs-iproc.c
+++ b/drivers/gpio/gpio-xgs-iproc.c
@@ -224,7 +224,7 @@  static int iproc_gpio_probe(struct platform_device *pdev)
 	}
 
 	chip->gc.label = dev_name(dev);
-	if (of_property_read_u32(dn, "ngpios", &num_gpios))
+	if (!of_property_read_u32(dn, "ngpios", &num_gpios))
 		chip->gc.ngpio = num_gpios;
 
 	irq = platform_get_irq(pdev, 0);