mirror of
https://github.com/torvalds/linux.git
synced 2026-06-07 14:04:54 +02:00
gpiolib: Assign fwnode to parent's if no primary one provided
[ Upstream commit6cb59afe9e] 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:7cba1a4d5e("gpiolib: generalize devprop_gpiochip_set_names() for device properties") Fixes: 2afa97e9868f ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
c5fe922eaf
commit
b3901ceb12
|
|
@ -572,6 +572,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;
|
||||
|
|
@ -601,6 +602,12 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
|
|||
gc->of_node = gdev->dev.of_node;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user