Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 545ebd9a authored by Linus Walleij's avatar Linus Walleij
Browse files

gpio: drop lock before reading GPIO direction



When adding the gpiochip, the GPIO HW drivers' callback get_direction()
could get called in atomic context. Some of the GPIO HW drivers may
sleep when accessing the register.

Move the lock before initializing the descriptors.

Reported-by: default avatarLaxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 54d77198
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -629,6 +629,8 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data)
		goto err_free_label;
	}

	spin_unlock_irqrestore(&gpio_lock, flags);

	for (i = 0; i < chip->ngpio; i++) {
		struct gpio_desc *desc = &gdev->descs[i];

@@ -660,8 +662,6 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data)
		}
	}

	spin_unlock_irqrestore(&gpio_lock, flags);

#ifdef CONFIG_PINCTRL
	INIT_LIST_HEAD(&gdev->pin_ranges);
#endif