gpio: clean up gpiochip_remove
Clean up gpiochip_remove somewhat and only output warning about removing chip with GPIOs requested once. Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
8becdc18c3
commit
fab28b89a1
|
@ -325,8 +325,10 @@ static void gpiochip_free_hogs(struct gpio_chip *chip);
|
||||||
*/
|
*/
|
||||||
void gpiochip_remove(struct gpio_chip *chip)
|
void gpiochip_remove(struct gpio_chip *chip)
|
||||||
{
|
{
|
||||||
|
struct gpio_desc *desc;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
unsigned id;
|
unsigned id;
|
||||||
|
bool requested = false;
|
||||||
|
|
||||||
gpiochip_unexport(chip);
|
gpiochip_unexport(chip);
|
||||||
|
|
||||||
|
@ -339,15 +341,17 @@ void gpiochip_remove(struct gpio_chip *chip)
|
||||||
|
|
||||||
spin_lock_irqsave(&gpio_lock, flags);
|
spin_lock_irqsave(&gpio_lock, flags);
|
||||||
for (id = 0; id < chip->ngpio; id++) {
|
for (id = 0; id < chip->ngpio; id++) {
|
||||||
if (test_bit(FLAG_REQUESTED, &chip->desc[id].flags))
|
desc = &chip->desc[id];
|
||||||
dev_crit(chip->dev, "REMOVING GPIOCHIP WITH GPIOS STILL REQUESTED\n");
|
desc->chip = NULL;
|
||||||
|
if (test_bit(FLAG_REQUESTED, &desc->flags))
|
||||||
|
requested = true;
|
||||||
}
|
}
|
||||||
for (id = 0; id < chip->ngpio; id++)
|
|
||||||
chip->desc[id].chip = NULL;
|
|
||||||
|
|
||||||
list_del(&chip->list);
|
list_del(&chip->list);
|
||||||
spin_unlock_irqrestore(&gpio_lock, flags);
|
spin_unlock_irqrestore(&gpio_lock, flags);
|
||||||
|
|
||||||
|
if (requested)
|
||||||
|
dev_crit(chip->dev, "REMOVING GPIOCHIP WITH GPIOS STILL REQUESTED\n");
|
||||||
|
|
||||||
kfree(chip->desc);
|
kfree(chip->desc);
|
||||||
chip->desc = NULL;
|
chip->desc = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue