]> asedeno.scripts.mit.edu Git - linux.git/commit
regulator: core: Track dangling GPIO descriptors
authorLinus Walleij <linus.walleij@linaro.org>
Thu, 6 Dec 2018 12:43:37 +0000 (13:43 +0100)
committerMark Brown <broonie@kernel.org>
Tue, 11 Dec 2018 01:02:57 +0000 (01:02 +0000)
commit0edb040d416ab350c02ac710233349aeaf8c2a26
treee0ebbe188ee790a84c21aeb21558a14818087d4f
parentc32569e358adea225f053ef9d97a4c8c18be8743
regulator: core: Track dangling GPIO descriptors

If a GPIO descriptor is passed to the regulator_register()
function inside the config->ena_gpiod callers must be
sure that once they call this API the regulator core
owns that descriptor and will make sure to issue
gpiod_put() on it, no matter whether the call is
successful or not.

For device tree regulators, the regulator core will
automatically set up regulator init data from the device
tree when registering a regulator by calling
regulator_of_get_init_data() which in turn calls down to
the regulator driver's .of_parse_cb() callback.
This callback (in drivers such as for max77686) may also
choose to fill in the config->ena_gpiod field with a GPIO
descriptor.

Harden the errorpath of regulator_register() to
properly gpiod_put() any passed in cfg->ena_gpiod
or any gpiod coming from the device tree on any type
of error.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/core.c