All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH next] gpiolib: check for parent device in devprop_gpiochip_set_names()
@ 2020-09-16 13:43 Bartosz Golaszewski
  2020-09-16 14:29 ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Bartosz Golaszewski @ 2020-09-16 13:43 UTC (permalink / raw)
  To: Linus Walleij, Mika Westerberg, Andy Shevchenko, Kent Gibson,
	Anders Roxell
  Cc: linux-gpio, linux-next, linux-kernel, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

It's possible for a GPIO chip to not have a parent device (whose
properties we inspect for 'gpio-line-names'). In this case we should
simply return from devprop_gpiochip_set_names(). Add an appropriate
check for this use-case.

Fixes: 7cba1a4d5e16 ("gpiolib: generalize devprop_gpiochip_set_names() for device properties")
Reported-by: Anders Roxell <anders.roxell@linaro.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/gpio/gpiolib.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index b7b608ef9..ac2c77edc 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -375,6 +375,9 @@ static int devprop_gpiochip_set_names(struct gpio_chip *chip)
 	int ret, i;
 	int count;
 
+	if (!dev)
+		return 0;
+
 	count = device_property_string_array_count(dev, "gpio-line-names");
 	if (count < 0)
 		return 0;
-- 
2.26.1


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

* Re: [PATCH next] gpiolib: check for parent device in devprop_gpiochip_set_names()
  2020-09-16 13:43 [PATCH next] gpiolib: check for parent device in devprop_gpiochip_set_names() Bartosz Golaszewski
@ 2020-09-16 14:29 ` Andy Shevchenko
  2020-09-16 14:47   ` Bartosz Golaszewski
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2020-09-16 14:29 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Mika Westerberg, Kent Gibson, Anders Roxell,
	linux-gpio, linux-next, linux-kernel, Bartosz Golaszewski

On Wed, Sep 16, 2020 at 03:43:27PM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> It's possible for a GPIO chip to not have a parent device (whose
> properties we inspect for 'gpio-line-names'). In this case we should
> simply return from devprop_gpiochip_set_names(). Add an appropriate
> check for this use-case.

Ah, nice!
Can we also add a small comment in the code, b/c w/o it I would stumble over
and eager to remove looks-as-unneeded check?
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Fixes: 7cba1a4d5e16 ("gpiolib: generalize devprop_gpiochip_set_names() for device properties")
> Reported-by: Anders Roxell <anders.roxell@linaro.org>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
>  drivers/gpio/gpiolib.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index b7b608ef9..ac2c77edc 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -375,6 +375,9 @@ static int devprop_gpiochip_set_names(struct gpio_chip *chip)
>  	int ret, i;
>  	int count;
>  
> +	if (!dev)
> +		return 0;
> +
>  	count = device_property_string_array_count(dev, "gpio-line-names");
>  	if (count < 0)
>  		return 0;
> -- 
> 2.26.1
> 

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH next] gpiolib: check for parent device in devprop_gpiochip_set_names()
  2020-09-16 14:29 ` Andy Shevchenko
@ 2020-09-16 14:47   ` Bartosz Golaszewski
  2020-09-16 21:25     ` Anders Roxell
  0 siblings, 1 reply; 4+ messages in thread
From: Bartosz Golaszewski @ 2020-09-16 14:47 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linus Walleij, Mika Westerberg, Kent Gibson, Anders Roxell,
	open list:GPIO SUBSYSTEM, Linux Next Mailing List,
	Linux Kernel Mailing List, Bartosz Golaszewski

On Wed, Sep 16, 2020 at 4:29 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Wed, Sep 16, 2020 at 03:43:27PM +0200, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> >
> > It's possible for a GPIO chip to not have a parent device (whose
> > properties we inspect for 'gpio-line-names'). In this case we should
> > simply return from devprop_gpiochip_set_names(). Add an appropriate
> > check for this use-case.
>
> Ah, nice!
> Can we also add a small comment in the code, b/c w/o it I would stumble over
> and eager to remove looks-as-unneeded check?
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Sure, I'll make a v2 then.

Bart

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

* Re: [PATCH next] gpiolib: check for parent device in devprop_gpiochip_set_names()
  2020-09-16 14:47   ` Bartosz Golaszewski
@ 2020-09-16 21:25     ` Anders Roxell
  0 siblings, 0 replies; 4+ messages in thread
From: Anders Roxell @ 2020-09-16 21:25 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Andy Shevchenko, Linus Walleij, Mika Westerberg, Kent Gibson,
	open list:GPIO SUBSYSTEM, Linux Next Mailing List,
	Linux Kernel Mailing List, Bartosz Golaszewski

On Wed, 16 Sep 2020 at 16:47, Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> On Wed, Sep 16, 2020 at 4:29 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > On Wed, Sep 16, 2020 at 03:43:27PM +0200, Bartosz Golaszewski wrote:
> > > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > >
> > > It's possible for a GPIO chip to not have a parent device (whose
> > > properties we inspect for 'gpio-line-names'). In this case we should
> > > simply return from devprop_gpiochip_set_names(). Add an appropriate
> > > check for this use-case.
> >
> > Ah, nice!
> > Can we also add a small comment in the code, b/c w/o it I would stumble over
> > and eager to remove looks-as-unneeded check?
> > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Tested-by: Anders Roxell <anders.roxell@linaro.org>

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

end of thread, other threads:[~2020-09-16 22:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-16 13:43 [PATCH next] gpiolib: check for parent device in devprop_gpiochip_set_names() Bartosz Golaszewski
2020-09-16 14:29 ` Andy Shevchenko
2020-09-16 14:47   ` Bartosz Golaszewski
2020-09-16 21:25     ` Anders Roxell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.