Skip to content

Commit b12ef03

Browse files
Dan Murphyjacek-anaszewski
authored andcommitted
leds: lp8860: Add regulator enable during init
Add the regulator enable call during initialization. If init fails then disable the regulator. Also during init the gpio gets set low even on a passing case so add if everything passes then return. Signed-off-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
1 parent 8a7a76c commit b12ef03

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

drivers/leds/leds-lp8860.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,15 @@ static int lp8860_init(struct lp8860_led *led)
247247
unsigned int read_buf;
248248
int ret, i, reg_count;
249249

250+
if (led->regulator) {
251+
ret = regulator_enable(led->regulator);
252+
if (ret) {
253+
dev_err(&led->client->dev,
254+
"Failed to enable regulator\n");
255+
return ret;
256+
}
257+
}
258+
250259
if (led->enable_gpio)
251260
gpiod_direction_output(led->enable_gpio, 1);
252261

@@ -282,12 +291,25 @@ static int lp8860_init(struct lp8860_led *led)
282291
ret = regmap_write(led->regmap,
283292
LP8860_EEPROM_CNTRL,
284293
LP8860_PROGRAM_EEPROM);
285-
if (ret)
294+
if (ret) {
286295
dev_err(&led->client->dev, "Failed programming EEPROM\n");
296+
goto out;
297+
}
298+
299+
return ret;
300+
287301
out:
288302
if (ret)
289303
if (led->enable_gpio)
290304
gpiod_direction_output(led->enable_gpio, 0);
305+
306+
if (led->regulator) {
307+
ret = regulator_disable(led->regulator);
308+
if (ret)
309+
dev_err(&led->client->dev,
310+
"Failed to disable regulator\n");
311+
}
312+
291313
return ret;
292314
}
293315

0 commit comments

Comments
 (0)