Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Linus Walleij and committed by
Mark Brown
d03c63db fe6c473e

+9 -5
+9 -5
drivers/regulator/max77686-regulator.c
··· 250 250 struct regulator_config *config) 251 251 { 252 252 struct max77686_data *max77686 = config->driver_data; 253 + int ret; 253 254 254 255 switch (desc->id) { 255 256 case MAX77686_BUCK8: 256 257 case MAX77686_BUCK9: 257 258 case MAX77686_LDO20 ... MAX77686_LDO22: 258 - config->ena_gpiod = devm_gpiod_get_from_of_node(max77686->dev, 259 - np, 259 + config->ena_gpiod = gpiod_get_from_of_node(np, 260 260 "maxim,ena", 261 261 0, 262 262 GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE, ··· 271 271 if (config->ena_gpiod) { 272 272 set_bit(desc->id, max77686->gpio_enabled); 273 273 274 - return regmap_update_bits(config->regmap, desc->enable_reg, 275 - desc->enable_mask, 276 - MAX77686_GPIO_CONTROL); 274 + ret = regmap_update_bits(config->regmap, desc->enable_reg, 275 + desc->enable_mask, 276 + MAX77686_GPIO_CONTROL); 277 + if (ret) { 278 + gpiod_put(config->ena_gpiod); 279 + config->ena_gpiod = NULL; 280 + } 277 281 } 278 282 279 283 return 0;