Here is a second iteration of these fixups after thinking
over Charles Keepax excellent comments on the first series
of fixes.

To make sure GPIO descriptors are never left dangling
(as far as I can tell!) I use this stepwise approach:

1. Fix the regulator_register() in the core to guarantee
   that after calling this with a valid GPIO descriptor
   in ena_gpiod it will be gpiod_put() if there is any
   problem.

2. Fix up simple descriptor consumers to just gpiod_get()
   and let the core take over the descriptor. Only handle
   the errorpath up to this point.

3. Export gpiod_get_from_of_node() and let max77686
   obtain a GPIO descriptor from the device tree without
   any devres make-up in the DT parsing callback.

4. Invent devm_gpiod_unhinge() that will remove the devres
   monitoring of a devm_* allocated GPIO descriptor
   right before handling it over to the regulator core,
   and use this in the otherwise hairy da9211,
   s5m8767, tps65090 and s2mps11 drivers.

Linus Walleij (13):
  regulator: core: Track dangling GPIO descriptors
  regulator: fixed: Let core handle GPIO descriptor
  regulator: lm363x: Let core handle GPIO descriptor
  regulator: lp8788-ldo: Let core handle GPIO descriptor
  regulator: max8952: Let core handle GPIO descriptor
  regulator: max8973: Let core handle GPIO descriptor
  gpio: Export gpiod_get_from_of_node()
  regulator: max77686: Let core handle GPIO descriptor
  gpio: Add devm_gpiod_unhinge()
  regulator: da9211: Hand over GPIO to regulator core
  regulator: s5m8767: Hand over GPIO to regulator core
  regulator: tps65090: Hand over GPIO to regulator core
  regulator: s2mps11: Hand over GPIO to regulator core

 Documentation/driver-model/devres.txt  |  1 +
 drivers/gpio/gpiolib-devres.c          | 17 ++++++++
 drivers/gpio/gpiolib.h                 |  6 ---
 drivers/regulator/core.c               | 55 +++++++++++++++++++++-----
 drivers/regulator/da9211-regulator.c   |  6 +++
 drivers/regulator/fixed.c              |  6 ++-
 drivers/regulator/lm363x-regulator.c   |  8 +++-
 drivers/regulator/lp8788-ldo.c         |  8 +++-
 drivers/regulator/max77686-regulator.c | 14 ++++---
 drivers/regulator/max8952.c            | 10 +++--
 drivers/regulator/max8973-regulator.c  | 23 +++++++----
 drivers/regulator/s2mps11.c            |  7 +++-
 drivers/regulator/s5m8767.c            |  9 ++++-
 drivers/regulator/tps65090-regulator.c |  6 +++
 include/linux/gpio/consumer.h          | 23 +++++++++++
 15 files changed, 161 insertions(+), 38 deletions(-)

-- 
2.19.1

Reply via email to