aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert@linux-m68k.org>2016-12-19 12:29:23 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-01-19 14:18:00 -0500
commit86673e9331c929f43ff4c89bee056273ac2e3ed5 (patch)
treed9b74af29256b499d8efb84b5a47618f4b655c42
parent0a28f5393689576a7667a7ef42cb79eafe16b019 (diff)
gpio: Move freeing of GPIO hogs before numbing of the device
commit 5018ada69a04c8ac21d74bd682fceb8e42dc0f96 upstream. When removing a gpiochip that uses GPIO hogging (e.g. by unloading the chip's DT overlay), a warning is printed: gpio gpiochip8: REMOVING GPIOCHIP WITH GPIOS STILL REQUESTED This happens because gpiochip_free_hogs() is called after the gdev->chip pointer is reset to NULL. Hence __gpiod_free() cannot determine the chip in use, and cannot clear flags nor call the optional chip-specific .free() callback. Move the call to gpiochip_free_hogs() up to fix this. Fixes: ff2b135922992756 ("gpio: make the gpiochip a real device") Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/gpio/gpiolib.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 90621fb93941..92159313361b 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1317,12 +1317,12 @@ void gpiochip_remove(struct gpio_chip *chip)
1317 1317
1318 /* FIXME: should the legacy sysfs handling be moved to gpio_device? */ 1318 /* FIXME: should the legacy sysfs handling be moved to gpio_device? */
1319 gpiochip_sysfs_unregister(gdev); 1319 gpiochip_sysfs_unregister(gdev);
1320 gpiochip_free_hogs(chip);
1320 /* Numb the device, cancelling all outstanding operations */ 1321 /* Numb the device, cancelling all outstanding operations */
1321 gdev->chip = NULL; 1322 gdev->chip = NULL;
1322 gpiochip_irqchip_remove(chip); 1323 gpiochip_irqchip_remove(chip);
1323 acpi_gpiochip_remove(chip); 1324 acpi_gpiochip_remove(chip);
1324 gpiochip_remove_pin_ranges(chip); 1325 gpiochip_remove_pin_ranges(chip);
1325 gpiochip_free_hogs(chip);
1326 of_gpiochip_remove(chip); 1326 of_gpiochip_remove(chip);
1327 /* 1327 /*
1328 * We accept no more calls into the driver from this point, so 1328 * We accept no more calls into the driver from this point, so