gpiolib: Assign fwnode to parent's if no primary one provided
PATCH 1/1 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.
--- drivers/gpio/gpiolib.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpio/gpiolib.c +7 -0
@@ -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;
Signature · 1 line
2.30.2
Quoted 5 lines · 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.
Bart, I missed to add you as a Reporter, feel free to do that or tell me I'll send a v2.
Quoted 3 lines
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 <[email protected]>
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).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Bartosz Golaszewski
Tested-byQuoted 11 lines · Andy Shevchenko
Quoted 5 lines · 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.
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.
Quoted 4 lines
Quoted 3 lines
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 <[email protected]>
Quoted 8 lines
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
Thanks for debugging this! Applied!
Bartosz