Commit d03c63db authored by Linus Walleij's avatar Linus Walleij Committed by Mark Brown

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: 96392c3d ("regulator: max77686: Pass descriptor instead of GPIO number")
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Reviewed-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Tested-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent fe6c473e
...@@ -250,13 +250,13 @@ static int max77686_of_parse_cb(struct device_node *np, ...@@ -250,13 +250,13 @@ static int max77686_of_parse_cb(struct device_node *np,
struct regulator_config *config) struct regulator_config *config)
{ {
struct max77686_data *max77686 = config->driver_data; struct max77686_data *max77686 = config->driver_data;
int ret;
switch (desc->id) { switch (desc->id) {
case MAX77686_BUCK8: case MAX77686_BUCK8:
case MAX77686_BUCK9: case MAX77686_BUCK9:
case MAX77686_LDO20 ... MAX77686_LDO22: case MAX77686_LDO20 ... MAX77686_LDO22:
config->ena_gpiod = devm_gpiod_get_from_of_node(max77686->dev, config->ena_gpiod = gpiod_get_from_of_node(np,
np,
"maxim,ena", "maxim,ena",
0, 0,
GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE, GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE,
...@@ -271,9 +271,13 @@ static int max77686_of_parse_cb(struct device_node *np, ...@@ -271,9 +271,13 @@ static int max77686_of_parse_cb(struct device_node *np,
if (config->ena_gpiod) { if (config->ena_gpiod) {
set_bit(desc->id, max77686->gpio_enabled); set_bit(desc->id, max77686->gpio_enabled);
return regmap_update_bits(config->regmap, desc->enable_reg, ret = regmap_update_bits(config->regmap, desc->enable_reg,
desc->enable_mask, desc->enable_mask,
MAX77686_GPIO_CONTROL); MAX77686_GPIO_CONTROL);
if (ret) {
gpiod_put(config->ena_gpiod);
config->ena_gpiod = NULL;
}
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment