]> git.ipfire.org Git - people/arne_f/kernel.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)
committerJiri Slaby <jslaby@suse.cz>
Sat, 16 May 2015 07:12:43 +0000 (09:12 +0200)
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>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
drivers/gpio/gpiolib.c

index 8a9b61adcd872015c62b93bd1f87ee3a984510ea..9ba1bb0edab3fadac071dbf34364e28ee92a666a 100644 (file)
@@ -1257,6 +1257,8 @@ int gpiochip_remove(struct gpio_chip *chip)
        int             status = 0;
        unsigned        id;
 
+       gpiochip_unexport(chip);
+
        spin_lock_irqsave(&gpio_lock, flags);
 
        gpiochip_remove_pin_ranges(chip);
@@ -1277,9 +1279,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);