Linux LED subsystem development
 help / color / mirror / Atom feed
* [PATCH 1/6] leds: lp8860: Use regmap_multi_reg_write for EEPROM writes
@ 2025-04-07 18:35 Andrew Davis
  2025-04-07 18:35 ` [PATCH 2/6] leds: lp8860: Use new mutex guards to cleanup function exits Andrew Davis
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Andrew Davis @ 2025-04-07 18:35 UTC (permalink / raw)
  To: Pavel Machek, Lee Jones; +Cc: linux-leds, linux-kernel, Andrew Davis

This helper does the same thing as manual looping, use it instead.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/leds/leds-lp8860.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/leds/leds-lp8860.c b/drivers/leds/leds-lp8860.c
index 995f2adf85696..2b1c68e609495 100644
--- a/drivers/leds/leds-lp8860.c
+++ b/drivers/leds/leds-lp8860.c
@@ -103,12 +103,7 @@ struct lp8860_led {
 	struct regulator *regulator;
 };
 
-struct lp8860_eeprom_reg {
-	uint8_t reg;
-	uint8_t value;
-};
-
-static struct lp8860_eeprom_reg lp8860_eeprom_disp_regs[] = {
+static const struct reg_sequence lp8860_eeprom_disp_regs[] = {
 	{ LP8860_EEPROM_REG_0, 0xed },
 	{ LP8860_EEPROM_REG_1, 0xdf },
 	{ LP8860_EEPROM_REG_2, 0xdc },
@@ -238,7 +233,7 @@ static int lp8860_brightness_set(struct led_classdev *led_cdev,
 static int lp8860_init(struct lp8860_led *led)
 {
 	unsigned int read_buf;
-	int ret, i, reg_count;
+	int ret, reg_count;
 
 	if (led->regulator) {
 		ret = regulator_enable(led->regulator);
@@ -266,14 +261,10 @@ static int lp8860_init(struct lp8860_led *led)
 	}
 
 	reg_count = ARRAY_SIZE(lp8860_eeprom_disp_regs);
-	for (i = 0; i < reg_count; i++) {
-		ret = regmap_write(led->eeprom_regmap,
-				lp8860_eeprom_disp_regs[i].reg,
-				lp8860_eeprom_disp_regs[i].value);
-		if (ret) {
-			dev_err(&led->client->dev, "Failed writing EEPROM\n");
-			goto out;
-		}
+	ret = regmap_multi_reg_write(led->eeprom_regmap, lp8860_eeprom_disp_regs, reg_count);
+	if (ret) {
+		dev_err(&led->client->dev, "Failed writing EEPROM\n");
+		goto out;
 	}
 
 	ret = lp8860_unlock_eeprom(led, LP8860_LOCK_EEPROM);
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-04-11  9:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-07 18:35 [PATCH 1/6] leds: lp8860: Use regmap_multi_reg_write for EEPROM writes Andrew Davis
2025-04-07 18:35 ` [PATCH 2/6] leds: lp8860: Use new mutex guards to cleanup function exits Andrew Davis
2025-04-07 18:35 ` [PATCH 3/6] leds: lp8860: Remove default regs when not caching Andrew Davis
2025-04-07 18:35 ` [PATCH 4/6] leds: lp8860: Enable regulator using enable_optional helper Andrew Davis
2025-04-07 18:35 ` [PATCH 5/6] leds: lp8860: Only unlock in lp8860_unlock_eeprom() Andrew Davis
2025-04-07 18:35 ` [PATCH 6/6] leds: lp8860: Disable GPIO with devm action Andrew Davis
2025-04-11  9:01 ` [PATCH 1/6] leds: lp8860: Use regmap_multi_reg_write for EEPROM writes Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox