public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] gpio: pisosr: read ngpios as U32
@ 2025-08-06  9:15 Stefano Manni
  2025-08-11  7:56 ` Bartosz Golaszewski
  0 siblings, 1 reply; 4+ messages in thread
From: Stefano Manni @ 2025-08-06  9:15 UTC (permalink / raw)
  To: linus.walleij, brgl; +Cc: linux-gpio, linux-kernel, Stefano Manni

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


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

* Re: [PATCH v2] gpio: pisosr: read ngpios as U32
  2025-08-06  9:15 [PATCH v2] gpio: pisosr: read ngpios as U32 Stefano Manni
@ 2025-08-11  7:56 ` Bartosz Golaszewski
  2025-10-08 21:28   ` Stefano Manni
  0 siblings, 1 reply; 4+ messages in thread
From: Bartosz Golaszewski @ 2025-08-11  7:56 UTC (permalink / raw)
  To: Stefano Manni; +Cc: linus.walleij, linux-gpio, linux-kernel

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
>

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

* Re: [PATCH v2] gpio: pisosr: read ngpios as U32
  2025-08-11  7:56 ` Bartosz Golaszewski
@ 2025-10-08 21:28   ` Stefano Manni
  2025-10-09 10:06     ` Bartosz Golaszewski
  0 siblings, 1 reply; 4+ messages in thread
From: Stefano Manni @ 2025-10-08 21:28 UTC (permalink / raw)
  To: Bartosz Golaszewski; +Cc: linus.walleij, linux-gpio, linux-kernel



On lun, ago 11 2025 at 09:56:51 +02:00:00, Bartosz Golaszewski 
<brgl@bgdev.pl> wrote:
> 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,


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.


> 
>>  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?
> 

what do you mean with "generic device properties"?

Best,
Stefano
>> 



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

* Re: [PATCH v2] gpio: pisosr: read ngpios as U32
  2025-10-08 21:28   ` Stefano Manni
@ 2025-10-09 10:06     ` Bartosz Golaszewski
  0 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2025-10-09 10:06 UTC (permalink / raw)
  To: Stefano Manni; +Cc: linus.walleij, linux-gpio, linux-kernel

On Wed, Oct 8, 2025 at 11:28 PM Stefano Manni <stefano.manni@gmail.com> wrote:
>
>
>
> On lun, ago 11 2025 at 09:56:51 +02:00:00, Bartosz Golaszewski
> <brgl@bgdev.pl> wrote:
> > 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,
>
>
> 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.
>

So please put this into the commit message.

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

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

end of thread, other threads:[~2025-10-09 10:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-06  9:15 [PATCH v2] gpio: pisosr: read ngpios as U32 Stefano Manni
2025-08-11  7:56 ` Bartosz Golaszewski
2025-10-08 21:28   ` Stefano Manni
2025-10-09 10:06     ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox