Commit b12ef03a authored by Dan Murphy's avatar Dan Murphy Committed by Jacek Anaszewski

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: default avatarDan Murphy <dmurphy@ti.com>
Signed-off-by: default avatarJacek Anaszewski <jacek.anaszewski@gmail.com>
parent 8a7a76c8
...@@ -247,6 +247,15 @@ static int lp8860_init(struct lp8860_led *led) ...@@ -247,6 +247,15 @@ static int lp8860_init(struct lp8860_led *led)
unsigned int read_buf; unsigned int read_buf;
int ret, i, reg_count; 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) if (led->enable_gpio)
gpiod_direction_output(led->enable_gpio, 1); gpiod_direction_output(led->enable_gpio, 1);
...@@ -282,12 +291,25 @@ static int lp8860_init(struct lp8860_led *led) ...@@ -282,12 +291,25 @@ static int lp8860_init(struct lp8860_led *led)
ret = regmap_write(led->regmap, ret = regmap_write(led->regmap,
LP8860_EEPROM_CNTRL, LP8860_EEPROM_CNTRL,
LP8860_PROGRAM_EEPROM); LP8860_PROGRAM_EEPROM);
if (ret) if (ret) {
dev_err(&led->client->dev, "Failed programming EEPROM\n"); dev_err(&led->client->dev, "Failed programming EEPROM\n");
goto out;
}
return ret;
out: out:
if (ret) if (ret)
if (led->enable_gpio) if (led->enable_gpio)
gpiod_direction_output(led->enable_gpio, 0); 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; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment