linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: pisosr: read ngpios as U32
@ 2025-08-05 14:28 Stefano Manni
  2025-08-06  9:17 ` Stefano Manni
  0 siblings, 1 reply; 2+ messages in thread
From: Stefano Manni @ 2025-08-05 14:28 UTC (permalink / raw)
  To: linus.walleij, brgl
  Cc: linux-gpio, linux-kernel, Stefano Manni, Stefano Manni

From: Stefano Manni <stefano.manni@eletechsrl.it>

If of_property_read_u16() is used instead the value read
is always zero.

Signed-off-by: Stefano Manni <stefano.manni@eletechsrl.it>
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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] gpio: pisosr: read ngpios as U32
  2025-08-05 14:28 [PATCH] gpio: pisosr: read ngpios as U32 Stefano Manni
@ 2025-08-06  9:17 ` Stefano Manni
  0 siblings, 0 replies; 2+ messages in thread
From: Stefano Manni @ 2025-08-06  9:17 UTC (permalink / raw)
  To: linus.walleij, brgl; +Cc: linux-gpio, linux-kernel, Stefano Manni

Please take v2: 
https://lore.kernel.org/linux-gpio/20250806091531.109861-1-stefano.manni@gmail.com/T/#u

On mar, ago 5 2025 at 16:28:56 +02:00:00, Stefano Manni 
<stefano.manni@gmail.com> wrote:
> From: Stefano Manni <stefano.manni@eletechsrl.it>
> 
> If of_property_read_u16() is used instead the value read
> is always zero.
> 
> Signed-off-by: Stefano Manni <stefano.manni@eletechsrl.it>
> 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
> 



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-06  7:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-05 14:28 [PATCH] gpio: pisosr: read ngpios as U32 Stefano Manni
2025-08-06  9:17 ` Stefano Manni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).