gpiolib: No need to call gpiochip_remove_pin_ranges() twice
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 5 Nov 2019 18:06:54 +0000 (20:06 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 7 Nov 2019 09:12:46 +0000 (10:12 +0100)
commit2f4133bb5f14f49a99acf0cc55b84996dbfb4dff
tree8a42914bf7fb28ccdfb8f75ed00ca5d70602a5e0
parente42615ec233b30dfaf117b108d4cb49455b4df1d
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: e93fa3f24353 ("gpiolib: remove duplicate pin range code")
Depends-on: f7299d441a4d ("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>
drivers/gpio/gpiolib-of.c
drivers/gpio/gpiolib.c