drivers/gpio/gpio-pisosr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
If of_property_read_u16() is used instead the value read
is always zero.
Signed-off-by: Stefano Manni <stefano.manni@gmail.com>
---
drivers/gpio/gpio-pisosr.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-pisosr.c b/drivers/gpio/gpio-pisosr.c
index a69b74866a13..2dc1b1e021d2 100644
--- a/drivers/gpio/gpio-pisosr.c
+++ b/drivers/gpio/gpio-pisosr.c
@@ -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);
--
2.48.1
On Wed, Aug 6, 2025 at 9:17 AM Stefano Manni <stefano.manni@gmail.com> wrote: > > 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, > Signed-off-by: Stefano Manni <stefano.manni@gmail.com> > --- > drivers/gpio/gpio-pisosr.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpio/gpio-pisosr.c b/drivers/gpio/gpio-pisosr.c > index a69b74866a13..2dc1b1e021d2 100644 > --- a/drivers/gpio/gpio-pisosr.c > +++ b/drivers/gpio/gpio-pisosr.c > @@ -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; > + If you're touching this, can you switch to using generic device properties instead? Bart > + gpio->chip.ngpio = ngpio; > gpio->spi = spi; > > gpio->buffer_size = DIV_ROUND_UP(gpio->chip.ngpio, 8); > -- > 2.48.1 >
© 2016 - 2025 Red Hat, Inc.