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 <[email protected]>
---
 drivers/regulator/lp8788-ldo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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);
-- 
2.19.1

Reply via email to