lkml.org 
[lkml]   [2018]   [Nov]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 05/10] regulator: max8973: Let core handle GPIO descriptor
Date
Use the gpiod_get() rather than the devm_* version so that the
regulator core can handle the lifecycle of these descriptors.

Fixes: e7d2be696faa ("regulator: max8973: Pass descriptor instead of GPIO number")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/regulator/max8973-regulator.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
index e7a58b509032..6e11324cb9cf 100644
--- a/drivers/regulator/max8973-regulator.c
+++ b/drivers/regulator/max8973-regulator.c
@@ -632,7 +632,7 @@ static int max8973_probe(struct i2c_client *client,
struct max8973_chip *max;
bool pdata_from_dt = false;
unsigned int chip_id;
- struct gpio_desc *gpiod;
+ struct gpio_desc *gpiod = NULL;
enum gpiod_flags gflags;
int ret;

@@ -759,9 +759,9 @@ static int max8973_probe(struct i2c_client *client,
else
gflags = GPIOD_OUT_LOW;
gflags |= GPIOD_FLAGS_BIT_NONEXCLUSIVE;
- gpiod = devm_gpiod_get_optional(&client->dev,
- "maxim,enable",
- gflags);
+ gpiod = gpiod_get_optional(&client->dev,
+ "maxim,enable",
+ gflags);
if (IS_ERR(gpiod))
return PTR_ERR(gpiod);
if (gpiod) {
@@ -798,6 +798,8 @@ static int max8973_probe(struct i2c_client *client,

ret = max8973_init_dcdc(max, pdata);
if (ret < 0) {
+ if (gpiod)
+ gpiod_put(gpiod);
dev_err(max->dev, "Max8973 Init failed, err = %d\n", ret);
return ret;
}
@@ -811,6 +813,8 @@ static int max8973_probe(struct i2c_client *client,
/* Register the regulators */
rdev = devm_regulator_register(&client->dev, &max->desc, &config);
if (IS_ERR(rdev)) {
+ if (gpiod)
+ gpiod_put(gpiod);
ret = PTR_ERR(rdev);
dev_err(max->dev, "regulator register failed, err %d\n", ret);
return ret;
--
2.19.1
\
 
 \ /
  Last update: 2018-11-28 11:44    [W:0.141 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site