]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
gpio: unregister gpiochip device before removing it
authorJohan Hovold <johan@kernel.org>
Mon, 12 Jan 2015 16:12:29 +0000 (17:12 +0100)
committerLuis Henriques <luis.henriques@canonical.com>
Wed, 20 May 2015 12:26:00 +0000 (13:26 +0100)
commit 01cca93a9491ed95992523ff7e79dd9bfcdea8e0 upstream.

Unregister gpiochip device (used to export information through sysfs)
before removing it internally. This way removal will reverse addition.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
[ luis: backported to 3.16: used Johan's backport to 3.14 ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
drivers/gpio/gpiolib.c

index d9b8844e27156076d435a326c3bbc9d5c6302f23..3f07d8aa848a8a961723719061fdfc650b4d4329 100644 (file)
@@ -1287,6 +1287,8 @@ int gpiochip_remove(struct gpio_chip *chip)
        int             status = 0;
        unsigned        id;
 
+       gpiochip_unexport(chip);
+
        gpiochip_irqchip_remove(chip);
 
        acpi_gpiochip_remove(chip);
@@ -1309,9 +1311,6 @@ int gpiochip_remove(struct gpio_chip *chip)
 
        spin_unlock_irqrestore(&gpio_lock, flags);
 
-       if (status == 0)
-               gpiochip_unexport(chip);
-
        return status;
 }
 EXPORT_SYMBOL_GPL(gpiochip_remove);