linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] gpiolib: Assign fwnode to parent's if no primary one provided
@ 2021-03-15 18:44 Andy Shevchenko
  2021-03-15 18:49 ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2021-03-15 18:44 UTC (permalink / raw)
  To: linux-gpio, linux-kernel
  Cc: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko

In case when the properties are supplied in the secondary fwnode
(for example, built-in device properties) the fwnode pointer left
unassigned. This makes unable to retrieve them.

Assign fwnode to parent's if no primary one provided.

Fixes: 7cba1a4d5e16 ("gpiolib: generalize devprop_gpiochip_set_names() for device properties")
Fixes: 2afa97e9868f ("gpiolib: Read "gpio-line-names" from a firmware node")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpiolib.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 7ec0822c0505..569c62863748 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -571,6 +571,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
 			       struct lock_class_key *lock_key,
 			       struct lock_class_key *request_key)
 {
+	struct fwnode_handle *fwnode = gc->parent ? dev_fwnode(gc->parent) : NULL;
 	unsigned long	flags;
 	int		ret = 0;
 	unsigned	i;
@@ -594,6 +595,12 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
 
 	of_gpio_dev_init(gc, gdev);
 
+	/*
+	 * Assign fwnode depending on the result of the previous calls,
+	 * if none of them succeed, assign it to the parent's one.
+	 */
+	gdev->dev.fwnode = dev_fwnode(&gdev->dev) ?: fwnode;
+
 	gdev->id = ida_alloc(&gpio_ida, GFP_KERNEL);
 	if (gdev->id < 0) {
 		ret = gdev->id;
-- 
2.30.2


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

* Re: [PATCH v1 1/1] gpiolib: Assign fwnode to parent's if no primary one provided
  2021-03-15 18:44 [PATCH v1 1/1] gpiolib: Assign fwnode to parent's if no primary one provided Andy Shevchenko
@ 2021-03-15 18:49 ` Andy Shevchenko
  2021-03-16  9:19   ` Bartosz Golaszewski
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2021-03-15 18:49 UTC (permalink / raw)
  To: linux-gpio, linux-kernel; +Cc: Linus Walleij, Bartosz Golaszewski

On Mon, Mar 15, 2021 at 08:44:30PM +0200, Andy Shevchenko wrote:
> In case when the properties are supplied in the secondary fwnode
> (for example, built-in device properties) the fwnode pointer left
> unassigned. This makes unable to retrieve them.
> 
> Assign fwnode to parent's if no primary one provided.

Bart, I missed to add you as a Reporter, feel free to do that or tell me I'll
send a v2.

> Fixes: 7cba1a4d5e16 ("gpiolib: generalize devprop_gpiochip_set_names() for device properties")
> Fixes: 2afa97e9868f ("gpiolib: Read "gpio-line-names" from a firmware node")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Side note: The patch done in this way to avoid conflicts with the future
(for-next) code once it will be in upstream (v5.12-rcX).

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v1 1/1] gpiolib: Assign fwnode to parent's if no primary one provided
  2021-03-15 18:49 ` Andy Shevchenko
@ 2021-03-16  9:19   ` Bartosz Golaszewski
  0 siblings, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2021-03-16  9:19 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-gpio, LKML, Linus Walleij

On Mon, Mar 15, 2021 at 7:49 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Mon, Mar 15, 2021 at 08:44:30PM +0200, Andy Shevchenko wrote:
> > In case when the properties are supplied in the secondary fwnode
> > (for example, built-in device properties) the fwnode pointer left
> > unassigned. This makes unable to retrieve them.
> >
> > Assign fwnode to parent's if no primary one provided.
>
> Bart, I missed to add you as a Reporter, feel free to do that or tell me I'll
> send a v2.
>

No need, I added myself.

> > Fixes: 7cba1a4d5e16 ("gpiolib: generalize devprop_gpiochip_set_names() for device properties")
> > Fixes: 2afa97e9868f ("gpiolib: Read "gpio-line-names" from a firmware node")
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> Side note: The patch done in this way to avoid conflicts with the future
> (for-next) code once it will be in upstream (v5.12-rcX).
>
> --
> With Best Regards,
> Andy Shevchenko
>
>

Tested-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Thanks for debugging this! Applied!

Bartosz

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

end of thread, other threads:[~2021-03-16  9:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-15 18:44 [PATCH v1 1/1] gpiolib: Assign fwnode to parent's if no primary one provided Andy Shevchenko
2021-03-15 18:49 ` Andy Shevchenko
2021-03-16  9:19   ` Bartosz Golaszewski

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