mirror of
https://github.com/torvalds/linux.git
synced 2025-11-06 11:39:24 +02:00
gpiolib: No need to call gpiochip_remove_pin_ranges() twice
of_gpiochip_add(), when fails, calls gpiochip_remove_pin_ranges().
ADD:
gpiochip_add_data_with_key() ->
of_gpiochip_add() -> (ERROR path)
gpiochip_remove_pin_ranges()
At the same time of_gpiochip_remove() calls exactly the above mentioned
function unconditionally and so does gpiochip_remove().
REMOVE:
gpiochip_remove() ->
gpiochip_remove_pin_ranges()
of_gpiochip_remove() ->
gpiochip_remove_pin_ranges()
Since gpiochip_remove() calls gpiochip_remove_pin_ranges() unconditionally,
we have duplicate call to the same function when it's not necessary.
Move gpiochip_remove_pin_ranges() from of_gpiochip_add() to gpiochip_add()
to avoid duplicate calls and be consistent with the explicit call in
gpiochip_remove().
Fixes: e93fa3f243 ("gpiolib: remove duplicate pin range code")
Depends-on: f7299d441a ("gpio: of: Fix of_gpiochip_add() error path")
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
e42615ec23
commit
2f4133bb5f
2 changed files with 3 additions and 5 deletions
|
|
@ -885,16 +885,13 @@ int of_gpiochip_add(struct gpio_chip *chip)
|
||||||
of_node_get(chip->of_node);
|
of_node_get(chip->of_node);
|
||||||
|
|
||||||
ret = of_gpiochip_scan_gpios(chip);
|
ret = of_gpiochip_scan_gpios(chip);
|
||||||
if (ret) {
|
if (ret)
|
||||||
of_node_put(chip->of_node);
|
of_node_put(chip->of_node);
|
||||||
gpiochip_remove_pin_ranges(chip);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void of_gpiochip_remove(struct gpio_chip *chip)
|
void of_gpiochip_remove(struct gpio_chip *chip)
|
||||||
{
|
{
|
||||||
gpiochip_remove_pin_ranges(chip);
|
|
||||||
of_node_put(chip->of_node);
|
of_node_put(chip->of_node);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1448,6 +1448,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data,
|
||||||
gpiochip_free_hogs(chip);
|
gpiochip_free_hogs(chip);
|
||||||
of_gpiochip_remove(chip);
|
of_gpiochip_remove(chip);
|
||||||
err_free_gpiochip_mask:
|
err_free_gpiochip_mask:
|
||||||
|
gpiochip_remove_pin_ranges(chip);
|
||||||
gpiochip_free_valid_mask(chip);
|
gpiochip_free_valid_mask(chip);
|
||||||
err_remove_from_list:
|
err_remove_from_list:
|
||||||
spin_lock_irqsave(&gpio_lock, flags);
|
spin_lock_irqsave(&gpio_lock, flags);
|
||||||
|
|
@ -1503,8 +1504,8 @@ void gpiochip_remove(struct gpio_chip *chip)
|
||||||
gdev->chip = NULL;
|
gdev->chip = NULL;
|
||||||
gpiochip_irqchip_remove(chip);
|
gpiochip_irqchip_remove(chip);
|
||||||
acpi_gpiochip_remove(chip);
|
acpi_gpiochip_remove(chip);
|
||||||
gpiochip_remove_pin_ranges(chip);
|
|
||||||
of_gpiochip_remove(chip);
|
of_gpiochip_remove(chip);
|
||||||
|
gpiochip_remove_pin_ranges(chip);
|
||||||
gpiochip_free_valid_mask(chip);
|
gpiochip_free_valid_mask(chip);
|
||||||
/*
|
/*
|
||||||
* We accept no more calls into the driver from this point, so
|
* We accept no more calls into the driver from this point, so
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue