[PATCH 00/15 v3] Regulator ena_gpiod fixups

From: Linus Walleij
Date: Wed Dec 05 2018 - 07:47:33 EST


Here is a third iteration of these fixups after thinking
over Marek's remarks on the v2 version.

Also available in git branch
gpio-descriptors-regulator-fixup in the GPIO git tree:
https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git/log/?h=gpio-descriptors-regulator-fixup

I added two fixup item to the list: making the gpiod
from of node respect nonexlusive flags and fixing the
shared regulators in devm_gpiod_get*.

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. Make gpiod_get_from_of_node() respect the
GPIOD_FLAGS_BIT_NONEXCLUSIVE flag.

5. Fix up devm_gpiod_get_* to respect the
GPIOD_FLAGS_BIT_NONEXCLUSIVE flag.

6. 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 (15):
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: Enable nonexclusive gpiods from DT nodes
gpio: devres: Handle nonexclusive GPIOs
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 | 80 ++++++++++++++++++++++----
drivers/gpio/gpiolib.c | 2 +
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 ++++++++
16 files changed, 214 insertions(+), 50 deletions(-)

--
2.19.2