Skip to content

Commit

Permalink
leds: lp8860: Add regulator enable during init
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dan Murphy authored and Jacek Anaszewski committed Jan 8, 2018
1 parent 8a7a76c commit b12ef03
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion drivers/leds/leds-lp8860.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,15 @@ static int lp8860_init(struct lp8860_led *led)
unsigned int read_buf;
int ret, i, reg_count;

if (led->regulator) {
ret = regulator_enable(led->regulator);
if (ret) {
dev_err(&led->client->dev,
"Failed to enable regulator\n");
return ret;
}
}

if (led->enable_gpio)
gpiod_direction_output(led->enable_gpio, 1);

Expand Down Expand Up @@ -282,12 +291,25 @@ static int lp8860_init(struct lp8860_led *led)
ret = regmap_write(led->regmap,
LP8860_EEPROM_CNTRL,
LP8860_PROGRAM_EEPROM);
if (ret)
if (ret) {
dev_err(&led->client->dev, "Failed programming EEPROM\n");
goto out;
}

return ret;

out:
if (ret)
if (led->enable_gpio)
gpiod_direction_output(led->enable_gpio, 0);

if (led->regulator) {
ret = regulator_disable(led->regulator);
if (ret)
dev_err(&led->client->dev,
"Failed to disable regulator\n");
}

return ret;
}

Expand Down

0 comments on commit b12ef03

Please sign in to comment.