Skip to contentSkip to conversation

leds: lp8860: Fix linuxdoc format for structure

PATCH In review Dan Murphy 2 participants 3 messages Nov 15, 2017 – Nov 16, 2017 LED

lore
Share & tools
lore

Dan Murphy

author
#0 lore raw

PATCH 1/2 leds: lp8860: Fix linuxdoc format for structure

Fix the linuxdoc format defining the lp8860 structure.

---
 drivers/leds/leds-lp8860.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/leds-lp8860.c +1 -1
index 3e70775a2d54..91b6c5fbd361 100644
@@ -98,7 +98,7 @@
  * @enable_gpio - VDDIO/EN gpio to enable communication interface
  * @regulator - LED supply regulator pointer
  * @label - LED label
-**/
+ */
 struct lp8860_led {
 	struct mutex lock;
 	struct i2c_client *client;
Signature · 1 line
2.15.0.124.g7668cbc60
author
#1 lore raw

PATCH 2/2 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.

---
 drivers/leds/leds-lp8860.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
drivers/leds/leds-lp8860.c +23 -1
index 91b6c5fbd361..f91a4fe25168 100644
@@ -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;
 }
 
Signature · 1 line
2.15.0.124.g7668cbc60
#2 lore raw

Re: [PATCH 2/2] leds: lp8860: Add regulator enable during init

Hi Dan,

Thanks for the patch set.

Both patches applied to the for-4.16 branch of linux-leds.git.

Best regards,
Jacek Anaszewski

Quoted 60 lines · Dan Murphy

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.

---
 drivers/leds/leds-lp8860.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
drivers/leds/leds-lp8860.c +23 -1
index 91b6c5fbd361..f91a4fe25168 100644
@@ -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;
 }