Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1544699 > unrolled thread

[PATCH] gpio: Move freeing of GPIO hogs before numbing of the device

Started byGeert Uytterhoeven <geert@linux-m68k.org>
First post2016-12-19 18:30 +0100
Last post2016-12-30 09:20 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] gpio: Move freeing of GPIO hogs before numbing of the device Geert Uytterhoeven <geert@linux-m68k.org> - 2016-12-19 18:30 +0100
    Re: [PATCH] gpio: Move freeing of GPIO hogs before numbing of the device Linus Walleij <linus.walleij@linaro.org> - 2016-12-30 09:20 +0100

#1544699 — [PATCH] gpio: Move freeing of GPIO hogs before numbing of the device

FromGeert Uytterhoeven <geert@linux-m68k.org>
Date2016-12-19 18:30 +0100
Subject[PATCH] gpio: Move freeing of GPIO hogs before numbing of the device
Message-ID<sQ9V7-2r7-15@gated-at.bofh.it>
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.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
I haven't verified that the problem happens on the below commit, but I
assume it does, so you may want to add:

Fixes: ff2b135922992756 ("gpio: make the gpiochip a real device")
---
 drivers/gpio/gpiolib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index f4c26c7826cdfc0b..86bf3b84ada56d42 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1317,12 +1317,12 @@ void gpiochip_remove(struct gpio_chip *chip)
 
 	/* FIXME: should the legacy sysfs handling be moved to gpio_device? */
 	gpiochip_sysfs_unregister(gdev);
+	gpiochip_free_hogs(chip);
 	/* Numb the device, cancelling all outstanding operations */
 	gdev->chip = NULL;
 	gpiochip_irqchip_remove(chip);
 	acpi_gpiochip_remove(chip);
 	gpiochip_remove_pin_ranges(chip);
-	gpiochip_free_hogs(chip);
 	of_gpiochip_remove(chip);
 	/*
 	 * We accept no more calls into the driver from this point, so
-- 
1.9.1

[toc] | [next] | [standalone]


#1548496

FromLinus Walleij <linus.walleij@linaro.org>
Date2016-12-30 09:20 +0100
Message-ID<sU0zT-1QO-15@gated-at.bofh.it>
In reply to#1544699
On Mon, Dec 19, 2016 at 6:29 PM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:

> 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.
>
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

Patch applied to fixes and tagged for stable.

Yours,
Linus Walleij

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web