diff mbox series

[01/10] regulator: fixed: Let core handle GPIO descriptor

Message ID 20181128104350.31902-2-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: efdfeb079cc3 ("regulator: fixed: Convert to use GPIO descriptor only")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

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

-- 
2.19.1
diff mbox series

Patch

diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index ccc29038f19a..52091ebf7164 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -183,7 +183,7 @@  static int reg_fixed_voltage_probe(struct platform_device *pdev)
 	 */
 	gflags |= GPIOD_FLAGS_BIT_NONEXCLUSIVE;
 
-	cfg.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, NULL, gflags);
+	cfg.ena_gpiod = gpiod_get_optional(&pdev->dev, NULL, gflags);
 	if (IS_ERR(cfg.ena_gpiod))
 		return PTR_ERR(cfg.ena_gpiod);
 
@@ -195,6 +195,8 @@  static int reg_fixed_voltage_probe(struct platform_device *pdev)
 	drvdata->dev = devm_regulator_register(&pdev->dev, &drvdata->desc,
 					       &cfg);
 	if (IS_ERR(drvdata->dev)) {
+		if (cfg.ena_gpiod)
+			gpiod_put(cfg.ena_gpiod);
 		ret = PTR_ERR(drvdata->dev);
 		dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret);
 		return ret;