Commit b968027c authored by Johan Hovold's avatar Johan Hovold Committed by Luis Henriques

gpio: fix sleep-while-atomic in gpiochip_remove

commit 6798acaa upstream.

Move direct and indirect calls to gpiochip_remove_pin_ranges outside of
spin lock as they can end up taking a mutex in pinctrl_remove_gpio_range.

Note that the pin ranges are already added outside of the lock.

Fixes: 9ef0d6f7 ("gpiolib: call pin removal in chip removal function")
Fixes: f23f1516 ("gpiolib: provide provision to register pin ranges")
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent cacd4bf5
...@@ -1275,12 +1275,10 @@ int gpiochip_remove(struct gpio_chip *chip) ...@@ -1275,12 +1275,10 @@ int gpiochip_remove(struct gpio_chip *chip)
gpiochip_irqchip_remove(chip); gpiochip_irqchip_remove(chip);
acpi_gpiochip_remove(chip); acpi_gpiochip_remove(chip);
spin_lock_irqsave(&gpio_lock, flags);
gpiochip_remove_pin_ranges(chip); gpiochip_remove_pin_ranges(chip);
of_gpiochip_remove(chip); of_gpiochip_remove(chip);
spin_lock_irqsave(&gpio_lock, flags);
for (id = 0; id < chip->ngpio; id++) { for (id = 0; id < chip->ngpio; id++) {
if (test_bit(FLAG_REQUESTED, &chip->desc[id].flags)) { if (test_bit(FLAG_REQUESTED, &chip->desc[id].flags)) {
status = -EBUSY; status = -EBUSY;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment