Skip to content

Commit 6cb59af

Browse files
andy-shevbrgl
authored andcommitted
gpiolib: Assign fwnode to parent's if no primary one provided
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: 7cba1a4 ("gpiolib: generalize devprop_gpiochip_set_names() for device properties") Fixes: 2afa97e ("gpiolib: Read "gpio-line-names" from a firmware node") Reported-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Tested-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
1 parent 3875721 commit 6cb59af

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

drivers/gpio/gpiolib.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
571571
struct lock_class_key *lock_key,
572572
struct lock_class_key *request_key)
573573
{
574+
struct fwnode_handle *fwnode = gc->parent ? dev_fwnode(gc->parent) : NULL;
574575
unsigned long flags;
575576
int ret = 0;
576577
unsigned i;
@@ -594,6 +595,12 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
594595

595596
of_gpio_dev_init(gc, gdev);
596597

598+
/*
599+
* Assign fwnode depending on the result of the previous calls,
600+
* if none of them succeed, assign it to the parent's one.
601+
*/
602+
gdev->dev.fwnode = dev_fwnode(&gdev->dev) ?: fwnode;
603+
597604
gdev->id = ida_alloc(&gpio_ida, GFP_KERNEL);
598605
if (gdev->id < 0) {
599606
ret = gdev->id;

0 commit comments

Comments
 (0)