From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-la0-f45.google.com ([209.85.215.45]:35698 "EHLO mail-la0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754169AbbEOKQD (ORCPT ); Fri, 15 May 2015 06:16:03 -0400 Received: by labbd9 with SMTP id bd9so112321396lab.2 for ; Fri, 15 May 2015 03:16:01 -0700 (PDT) From: Johan Hovold To: Greg Kroah-Hartman Cc: linus.walleij@linaro.org, stable@vger.kernel.org, Johan Hovold Subject: [PATCH-3.10 1/2] gpio: unregister gpiochip device before removing it Date: Fri, 15 May 2015 12:15:44 +0200 Message-Id: <1431684945-11886-1-git-send-email-johan@kernel.org> In-Reply-To: <20150515101457.GB13976@localhost> References: <20150515101457.GB13976@localhost> Sender: stable-owner@vger.kernel.org List-ID: 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 Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index ca1cb2d756c2..df4780810e83 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1265,6 +1265,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); @@ -1285,9 +1287,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); -- 2.3.6