summaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2018-12-06 07:43:43 -0500
committerMark Brown <broonie@kernel.org>2018-12-10 20:04:08 -0500
commitd03c63dbcaa1ee570d0435a7f79c7083ffb59245 (patch)
tree62ff650c161160ca4a524af4910b9aab5f1b98ab /drivers/regulator
parentfe6c473e3e41114301bfbf5710be56bf0eb233dc (diff)
regulator: max77686: Let core handle GPIO descriptor
Use the gpiod_get_from_of_node() rather than the devm_* version so that the regulator core can handle the lifecycle of these descriptors. Fix up the errorpath so that we free this descriptor if an error occurs in the callback. Rely on the regulator core to deal with it after this point: a previous patch fixed up the regulator core to properly dispose any GPIO descriptors once you call regulator_register(). Fixes: 96392c3d8ca4 ("regulator: max77686: Pass descriptor instead of GPIO number") 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>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/max77686-regulator.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/regulator/max77686-regulator.c b/drivers/regulator/max77686-regulator.c
index f5cee1775905..8020eb57374a 100644
--- a/drivers/regulator/max77686-regulator.c
+++ b/drivers/regulator/max77686-regulator.c
@@ -250,13 +250,13 @@ static int max77686_of_parse_cb(struct device_node *np,
250 struct regulator_config *config) 250 struct regulator_config *config)
251{ 251{
252 struct max77686_data *max77686 = config->driver_data; 252 struct max77686_data *max77686 = config->driver_data;
253 int ret;
253 254
254 switch (desc->id) { 255 switch (desc->id) {
255 case MAX77686_BUCK8: 256 case MAX77686_BUCK8:
256 case MAX77686_BUCK9: 257 case MAX77686_BUCK9:
257 case MAX77686_LDO20 ... MAX77686_LDO22: 258 case MAX77686_LDO20 ... MAX77686_LDO22:
258 config->ena_gpiod = devm_gpiod_get_from_of_node(max77686->dev, 259 config->ena_gpiod = gpiod_get_from_of_node(np,
259 np,
260 "maxim,ena", 260 "maxim,ena",
261 0, 261 0,
262 GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE, 262 GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE,
@@ -271,9 +271,13 @@ static int max77686_of_parse_cb(struct device_node *np,
271 if (config->ena_gpiod) { 271 if (config->ena_gpiod) {
272 set_bit(desc->id, max77686->gpio_enabled); 272 set_bit(desc->id, max77686->gpio_enabled);
273 273
274 return regmap_update_bits(config->regmap, desc->enable_reg, 274 ret = regmap_update_bits(config->regmap, desc->enable_reg,
275 desc->enable_mask, 275 desc->enable_mask,
276 MAX77686_GPIO_CONTROL); 276 MAX77686_GPIO_CONTROL);
277 if (ret) {
278 gpiod_put(config->ena_gpiod);
279 config->ena_gpiod = NULL;
280 }
277 } 281 }
278 282
279 return 0; 283 return 0;