Skip to contentSkip to conversation

leds: lm3601x: reset led controller during init

PATCH Superseded Jack Chen 2 participants 3 messages Jul 29, 2024 – Aug 1, 2024 LED

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jack Chen

author
#0 lore raw

PATCH 1/1 leds: lm3601x: reset led controller during init

LED controller should be reset during initialization to avoid abnormal behaviors. For example, when power to SoC is recycled but power to LED controller is not, LED controller should not presume to be in original state.

---
 drivers/leds/flash/leds-lm3601x.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/leds/flash/leds-lm3601x.c +4 -0
index 7e93c447fec5..978256310540 100644
@@ -434,6 +434,10 @@ static int lm3601x_probe(struct i2c_client *client)
 		return ret;
 	}
 
+	ret = regmap_write(led->regmap, LM3601X_DEV_ID_REG, LM3601X_SW_RESET);
+	if (ret)
+		dev_warn(&client->dev, "led controller is failed to reset\n");
+
 	mutex_init(&led->lock);
 
 	return lm3601x_register_leds(led, fwnode);
Signature · 1 line
2.46.0.rc1.232.g9752f9e123-goog
maintainer
#1 lore raw

Nit: Subject line descriptions start with an uppercase char in LED.

Quoted 15 lines

LED controller should be reset during initialization to avoid abnormal behaviors. For example, when power to SoC is recycled but power to LED controller is not, LED controller should not presume to be in original state.

---
 drivers/leds/flash/leds-lm3601x.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/leds/flash/leds-lm3601x.c +0 -0
index 7e93c447fec5..978256310540 100644

drivers/leds/flash/leds-lm3601x.c static int lm3601x_probe(struct i2c_client *client) · line 437

Quoted 4 lines
drivers/leds/flash/leds-lm3601x.c +1 -0
@@ -434,6 +434,10 @@ static int lm3601x_probe(struct i2c_client *client)
 		return ret;
 	}
 
+	ret = regmap_write(led->regmap, LM3601X_DEV_ID_REG, LM3601X_SW_RESET);

So this controller is reset via the ID register?

drivers/leds/flash/leds-lm3601x.c static int lm3601x_probe(struct i2c_client *client) · line 439

Quoted 2 lines
drivers/leds/flash/leds-lm3601x.c +2 -0
+	if (ret)
+		dev_warn(&client->dev, "led controller is failed to reset\n");

"LED controller failed to reset"

Or

"Failed to reset the LED controller"

Quoted 7 lines
drivers/leds/flash/leds-lm3601x.c +0 -0
 	mutex_init(&led->lock);
 
 	return lm3601x_register_leds(led, fwnode);
Signature · 1 line
2.46.0.rc1.232.g9752f9e123-goog
Signature · 1 line
Lee Jones [李琼斯]
author
#2 lore raw
Quoted 21 lines · Lee Jones

Nit: Subject line descriptions start with an uppercase char in LED.

Quoted 18 lines

LED controller should be reset during initialization to avoid abnormal behaviors. For example, when power to SoC is recycled but power to LED controller is not, LED controller should not presume to be in original state.

---
 drivers/leds/flash/leds-lm3601x.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/leds/flash/leds-lm3601x.c +0 -0
index 7e93c447fec5..978256310540 100644
@@ -434,6 +434,10 @@ static int lm3601x_probe(struct i2c_client *client)
              return ret;
      }
 
Quoted 3 lines

drivers/leds/flash/leds-lm3601x.c static int lm3601x_probe(struct i2c_client *client) · line 437

Quoted 1 line
drivers/leds/flash/leds-lm3601x.c +1 -0
+     ret = regmap_write(led->regmap, LM3601X_DEV_ID_REG, LM3601X_SW_RESET);

So this controller is reset via the ID register?

Yes, that is correct. The MSB of LM3601X_DEV_ID_REG.

Quoted 12 lines

drivers/leds/flash/leds-lm3601x.c static int lm3601x_probe(struct i2c_client *client) · line 439

Quoted 3 lines
drivers/leds/flash/leds-lm3601x.c +2 -0
+     if (ret)
+             dev_warn(&client->dev, "led controller is failed to reset\n");

"LED controller failed to reset"

Or

"Failed to reset the LED controller"

Quoted 2 lines
drivers/leds/flash/leds-lm3601x.c +0 -0
      mutex_init(&led->lock);
 
Quoted 8 lines
Quoted 5 lines
drivers/leds/flash/leds-lm3601x.c +0 -1
      return lm3601x_register_leds(led, fwnode);
--

2.46.0.rc1.232.g9752f9e123-goog

--
Lee Jones [李琼斯]

Thanks so much for feedback. I will send a V2 patch with changes.

Best regards
Jack Chen