gpio: pisosr: read ngpios as U32
PATCH v2 1/1 gpio: pisosr: read ngpios as U32
If of_property_read_u16() is used instead the value read is always zero.
--- drivers/gpio/gpio-pisosr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpio/gpio-pisosr.c +5 -1
@@ -117,6 +117,7 @@ static int pisosr_gpio_probe(struct spi_device *spi) {struct device *dev = &spi->dev;struct pisosr_gpio *gpio; +unsigned int ngpio;int ret; gpio =devm_kzalloc (dev,sizeof (*gpio),GFP_KERNEL );
@@ -125,8 +126,11 @@ static int pisosr_gpio_probe(struct spi_device *spi) gpio->chip = template_chip; gpio->chip.parent = dev; -of_property_read_u16 (dev->of_node,"ngpios" , &gpio->chip.ngpio); +if (of_property_read_u32 (dev->of_node,"ngpios" , &ngpio)) + ngpio =DEFAULT_NGPIO ; + + gpio->chip.ngpio = ngpio; gpio->spi = spi; gpio->buffer_size =DIV_ROUND_UP (gpio->chip.ngpio,8 );
Signature · 1 line
2.48.1
Quoted 4 lines · Stefano Manni
If
of_property_read_u16()is used instead the value read is always zero.
Please state more clearly what the problem is. This sentence is quite garbled,
Quoted 18 lines
Signed-off-by Stefano Manni <[email protected]>--- drivers/gpio/gpio-pisosr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/gpio/gpio-pisosr.c +1
-0@@ -117,6 +117,7 @@ static int pisosr_gpio_probe(struct spi_device *spi) {struct device *dev = &spi->dev;struct pisosr_gpio *gpio; +unsigned int ngpio;int ret; gpio =devm_kzalloc (dev,sizeof (*gpio),GFP_KERNEL );
drivers/gpio/gpio-pisosr.c static int pisosr_gpio_probe(struct spi_device *spi) · line 132
Quoted 8 lines
drivers/gpio/gpio-pisosr.c +3
-1@@ -125,8 +126,11 @@ static int pisosr_gpio_probe(struct spi_device *spi) gpio->chip = template_chip; gpio->chip.parent = dev; -of_property_read_u16 (dev->of_node,"ngpios" , &gpio->chip.ngpio); +if (of_property_read_u32 (dev->of_node,"ngpios" , &ngpio)) + ngpio =DEFAULT_NGPIO ; +
If you're touching this, can you switch to using generic device properties instead?
Bart
Quoted 7 lines
drivers/gpio/gpio-pisosr.c +1
-1+ gpio->chip.ngpio = ngpio; gpio->spi = spi; gpio->buffer_size =DIV_ROUND_UP (gpio->chip.ngpio,8 ); --2.48.1
Quoted 7 lines · Bartosz Golaszewski
Quoted 4 lines · Stefano Manni
If
of_property_read_u16()is used instead the value read is always zero.Please state more clearly what the problem is. This sentence is quite garbled,
the value returned by of_property_read_u16() is always zero, if of_property_read_u32() is used instead , then the returned value is the right one contained in the dts.
Quoted 27 lines
Quoted 27 lines
Signed-off-by Stefano Manni <[email protected]>---
drivers/gpio/gpio-pisosr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)diff --git
a/drivers/gpio/gpio-pisosr.cb/drivers/gpio/gpio-pisosr.cindexa69b74866a13..2dc1b1e021d2100644
---a/drivers/gpio/gpio-pisosr.c
+++b/drivers/gpio/gpio-pisosr.c
@@ -117,6 +117,7 @@ static int pisosr_gpio_probe(structspi_device
*spi){ struct device *dev = &spi->dev; struct pisosr_gpio *gpio; + unsigned int ngpio; int ret; gpio = devm_kzalloc(dev, sizeof(*gpio), GFP_KERNEL);@@ -125,8 +126,11 @@ static int pisosr_gpio_probe(struct
spi_device
*spi)gpio->chip = template_chip; gpio->chip.parent = dev;- of_property_read_u16(dev->of_node, "ngpios",
&gpio->chip.ngpio);
Quoted 7 lines
Quoted 3 lines
+ if (
of_property_read_u32(dev->of_node, "ngpios", &ngpio))
+ ngpio =DEFAULT_NGPIO;
+If you're touching this, can you switch to using generic device properties instead?
what do you mean with "generic device properties"?
Best,
Stefano
Quoted 1 line
Quoted 1 line
Quoted 12 lines · Stefano Manni
Quoted 7 lines · Bartosz Golaszewski
Quoted 4 lines · Stefano Manni
If
of_property_read_u16()is used instead the value read is always zero.
Quoted 9 lines
Quoted 2 lines
Please state more clearly what the problem is. This sentence is quite garbled,
the value returned by
of_property_read_u16()is always zero, ifof_property_read_u32()
is used instead , then the returned value is the right one contained in the dts.
So please put this into the commit message.
Quoted 7 lines
Quoted 4 lines
If you're touching this, can you switch to using generic device properties instead?
what do you mean with "generic device properties"?
Functions that allow to read properties through the fwnode associated with a device bound to a driver. In this case:device_property_read_u32().
Bart