lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250407183555.409687-4-afd@ti.com>
Date: Mon, 7 Apr 2025 13:35:53 -0500
From: Andrew Davis <afd@...com>
To: Pavel Machek <pavel@...nel.org>, Lee Jones <lee@...nel.org>
CC: <linux-leds@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        Andrew Davis
	<afd@...com>
Subject: [PATCH 4/6] 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@...com>
---
 drivers/leds/leds-lp8860.c | 31 ++++---------------------------
 1 file changed, 4 insertions(+), 27 deletions(-)

diff --git a/drivers/leds/leds-lp8860.c b/drivers/leds/leds-lp8860.c
index 4cd1b960d504f..f913a895d8a97 100644
--- a/drivers/leds/leds-lp8860.c
+++ b/drivers/leds/leds-lp8860.c
@@ -100,7 +100,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 +231,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 +272,6 @@ static int lp8860_init(struct lp8860_led *led)
 	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 +313,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 +365,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[] = {
-- 
2.39.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ