Skip to contentSkip to conversation

gpio: xgs-iproc: fix parsing of ngpios property

PATCH In review Jonas Gorski 6 participants 7 messages Oct 14, 2021 – Nov 2, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: xgs-iproc: fix parsing of ngpios property

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")

---
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(-)
drivers/gpio/gpio-xgs-iproc.c +1 -1
index ad5489a65d54..dd40277b9d06 100644
@@ -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);
Signature · 1 line
2.33.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Jonas Gorski

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")

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

Quoted 25 lines

---
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(-)
drivers/gpio/gpio-xgs-iproc.c +1 -1
index ad5489a65d54..dd40277b9d06 100644
@@ -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);
#4 lore raw
In reply to Jonas Gorski
Quoted 32 lines · Jonas Gorski

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")

---
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(-)
drivers/gpio/gpio-xgs-iproc.c +1 -2
index ad5489a65d54..dd40277b9d06 100644
@@ -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);
--
Quoted 2 lines

2.33.0

Queued for fixes.

Bart

#5 lore raw
In reply to Jonas Gorski

drivers/gpio/gpio-xgs-iproc.c static int iproc_gpio_probe(struct platform_device *pdev) · line 228

Quoted 7 lines · Jonas Gorski

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.

drivers/gpio/gpio-xgs-iproc.c +1 -1
-       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.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw
Quoted 10 lines · Andy Shevchenko

drivers/gpio/gpio-xgs-iproc.c static int iproc_gpio_probe(struct platform_device *pdev) · line 228

Quoted 7 lines · Jonas Gorski

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.

drivers/gpio/gpio-xgs-iproc.c +1 -1
-       if (of_property_read_u32(dn, "ngpios", &num_gpios))
+       if (!of_property_read_u32(dn, "ngpios", &num_gpios))
                chip->gc.ngpio = num_gpios;
Quoted 7 lines

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