diff options
author | Dan Murphy <dmurphy@ti.com> | 2017-11-15 20:52:13 +0100 |
---|---|---|
committer | Jacek Anaszewski <jacek.anaszewski@gmail.com> | 2018-01-08 21:28:10 +0100 |
commit | b12ef03a38b20e1bfaa163ed1632625fedd570ee (patch) | |
tree | 099ad982c09f0af33e98325f158ef3e56ec2d1a2 /drivers/leds | |
parent | leds: lp8860: Fix linuxdoc format for structure (diff) | |
download | linux-b12ef03a38b20e1bfaa163ed1632625fedd570ee.tar.xz linux-b12ef03a38b20e1bfaa163ed1632625fedd570ee.zip |
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>
Diffstat (limited to 'drivers/leds')
-rw-r--r-- | drivers/leds/leds-lp8860.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/drivers/leds/leds-lp8860.c b/drivers/leds/leds-lp8860.c index 91b6c5fbd361..f91a4fe25168 100644 --- a/drivers/leds/leds-lp8860.c +++ b/drivers/leds/leds-lp8860.c @@ -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); @@ -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; } |