Skip to content

Commit 3149860

Browse files
committed
Merge tag 'gpio-fixes-for-v5.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux
Pull gpio fixes from Bartosz Golaszewski: "Two fixes for the GPIO subsystem. Both address issues in the core GPIO code: - fix the return value in error path in gpiolib_dev_init() - fix the 'gpio-line-names' property handling correctly this time" * tag 'gpio-fixes-for-v5.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: gpiolib: Assign fwnode to parent's if no primary one provided gpiolib: Fix error return code in gpiolib_dev_init()
2 parents 6bfea14 + 6cb59af commit 3149860

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

drivers/gpio/gpiolib.c

Lines changed: 9 additions & 1 deletion
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;
@@ -4256,7 +4263,8 @@ static int __init gpiolib_dev_init(void)
42564263
return ret;
42574264
}
42584265

4259-
if (driver_register(&gpio_stub_drv) < 0) {
4266+
ret = driver_register(&gpio_stub_drv);
4267+
if (ret < 0) {
42604268
pr_err("gpiolib: could not register GPIO stub driver\n");
42614269
bus_unregister(&gpio_bus_type);
42624270
return ret;

0 commit comments

Comments
 (0)