diff mbox series

[03/10] regulator: lp8788-ldo: Let core handle GPIO descriptor

Message ID 20181128104350.31902-4-linus.walleij@linaro.org
State New
Headers show
Series Regulator ena_gpiod fixups | expand

Commit Message

Linus Walleij Nov. 28, 2018, 10:43 a.m. UTC
Use the gpiod_get() rather than the devm_* version so that the
regulator core can handle the lifecycle of these descriptors.

Fixes: 2468f0d51548 ("regulator: lp8788-ldo: Pass descriptor instead of GPIO number")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

---
 drivers/regulator/lp8788-ldo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

-- 
2.19.1
diff mbox series

Patch

diff --git a/drivers/regulator/lp8788-ldo.c b/drivers/regulator/lp8788-ldo.c
index 553b4790050f..416d073ec62c 100644
--- a/drivers/regulator/lp8788-ldo.c
+++ b/drivers/regulator/lp8788-ldo.c
@@ -502,7 +502,7 @@  static int lp8788_config_ldo_enable_mode(struct platform_device *pdev,
 	}
 
 	/* FIXME: check default mode for GPIO here: high or low? */
-	ldo->ena_gpiod = devm_gpiod_get_index_optional(&pdev->dev,
+	ldo->ena_gpiod = gpiod_get_index_optional(&pdev->dev,
 					       "enable",
 					       enable_id,
 					       GPIOD_OUT_HIGH |
@@ -548,6 +548,8 @@  static int lp8788_dldo_probe(struct platform_device *pdev)
 
 	rdev = devm_regulator_register(&pdev->dev, &lp8788_dldo_desc[id], &cfg);
 	if (IS_ERR(rdev)) {
+		if (ldo->ena_gpiod)
+			gpiod_put(ldo->ena_gpiod);
 		ret = PTR_ERR(rdev);
 		dev_err(&pdev->dev, "DLDO%d regulator register err = %d\n",
 				id + 1, ret);