summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Davis <afd@ti.com>2025-04-07 13:35:53 -0500
committerLee Jones <lee@kernel.org>2025-05-14 09:24:54 +0100
commitb0d6394094ee657f50b42b44f4903014d90e912a (patch)
tree327ff5d0b5d2e43e13229f4d8109fca1efb65fbc
parent0cb55e16bd842364340d24e2e368b9d6c5800423 (diff)
leds: lp8860: Enable regulator using enable_optional helper
This allows the regulator to be optional which is the same as done here with all the checks for NULL. This also disables on remove for us, so remove the manual disabling. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20250407183555.409687-4-afd@ti.com Signed-off-by: Lee Jones <lee@kernel.org>
-rw-r--r--drivers/leds/leds-lp8860.c32
1 files changed, 4 insertions, 28 deletions
diff --git a/drivers/leds/leds-lp8860.c b/drivers/leds/leds-lp8860.c
index 4cd1b960d504..2ceebdb5820e 100644
--- a/drivers/leds/leds-lp8860.c
+++ b/drivers/leds/leds-lp8860.c
@@ -91,7 +91,6 @@
* @regmap: Devices register map
* @eeprom_regmap: EEPROM register map
* @enable_gpio: VDDIO/EN gpio to enable communication interface
- * @regulator: LED supply regulator pointer
*/
struct lp8860_led {
struct mutex lock;
@@ -100,7 +99,6 @@ struct lp8860_led {
struct regmap *regmap;
struct regmap *eeprom_regmap;
struct gpio_desc *enable_gpio;
- struct regulator *regulator;
};
static const struct reg_sequence lp8860_eeprom_disp_regs[] = {
@@ -232,15 +230,6 @@ static int lp8860_init(struct lp8860_led *led)
unsigned int read_buf;
int ret, reg_count;
- if (led->regulator) {
- ret = regulator_enable(led->regulator);
- if (ret) {
- dev_err(&led->client->dev,
- "Failed to enable regulator\n");
- return ret;
- }
- }
-
gpiod_direction_output(led->enable_gpio, 1);
ret = lp8860_fault_check(led);
@@ -282,13 +271,6 @@ out:
if (ret)
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;
}
@@ -330,9 +312,10 @@ static int lp8860_probe(struct i2c_client *client)
return ret;
}
- led->regulator = devm_regulator_get(&client->dev, "vled");
- if (IS_ERR(led->regulator))
- led->regulator = NULL;
+ ret = devm_regulator_get_enable_optional(&client->dev, "vled");
+ if (ret && ret != -ENODEV)
+ return dev_err_probe(&client->dev, ret,
+ "Failed to enable vled regulator\n");
led->client = client;
led->led_dev.brightness_set_blocking = lp8860_brightness_set;
@@ -381,13 +364,6 @@ static void lp8860_remove(struct i2c_client *client)
int ret;
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");
- }
}
static const struct i2c_device_id lp8860_id[] = {