[PATCH 1/2] leds: flash: lm3643: Return to standby when the last output is switched off

From: Ruslan Koreev

Date: Thu Sep 24 2026 - 14:26:54 EST


Setting the torch brightness of an output to 0 only cleared its enable
bit and left the mode bits at torch (or flash), so the chip kept its
boost converter running with no output enabled. Likewise switching the
strobe off returned early when the output's enable bit had already been
cleared, leaving the mode bits at flash. Both were flagged by the
Sashiko review of the RFC, which Lee Jones asked to have addressed.

Clear the mode bits together with the enable bit whenever the sibling
output is not active, so that the chip goes back to standby when its
last output is switched off.

Signed-off-by: Ruslan Koreev <koreev.r@xxxxxxxxx>
---
drivers/leds/flash/leds-lm3643.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/leds/flash/leds-lm3643.c b/drivers/leds/flash/leds-lm3643.c
index 48e164261..bbe9358c9 100644
--- a/drivers/leds/flash/leds-lm3643.c
+++ b/drivers/leds/flash/leds-lm3643.c
@@ -271,9 +271,15 @@ static int lm3643_torch_set_brightness(struct led_classdev *led_cdev,
mode != LM3643_MODE_TORCH)
return -EBUSY;

- if (brightness == 0)
- return regmap_update_bits(led->regmap, LM3643_REG_ENABLE,
- chan->enable_bit, 0);
+ if (brightness == 0) {
+ unsigned int mask = chan->enable_bit;
+
+ /* Last active output: leave torch mode, back to standby */
+ if (!(enable & sibling_bit))
+ mask |= LM3643_MODE_MASK;
+
+ return regmap_update_bits(led->regmap, LM3643_REG_ENABLE, mask, 0);
+ }

ret = regmap_update_bits(led->regmap, chan->torch_br_reg, LM3643_TORCH_BR_MASK,
LM3643_TORCH_BR_CDEV_TO_CODE(brightness));
@@ -365,11 +371,16 @@ static int lm3643_flash_strobe_set(struct led_classdev_flash *fled_cdev, bool st
mode = enable_reg & LM3643_MODE_MASK;

if (!state) {
- if (mode != LM3643_MODE_FLASH || !(enable_reg & chan->enable_bit))
+ unsigned int mask = chan->enable_bit;
+
+ if (mode != LM3643_MODE_FLASH)
return 0;

- return regmap_update_bits(led->regmap, LM3643_REG_ENABLE,
- LM3643_MODE_MASK, LM3643_MODE_STANDBY);
+ /* Leave flash mode once no other output is strobing */
+ if (!(enable_reg & sibling_bit))
+ mask |= LM3643_MODE_MASK;
+
+ return regmap_update_bits(led->regmap, LM3643_REG_ENABLE, mask, 0);
}
if ((enable_reg & sibling_bit) && mode != LM3643_MODE_STANDBY)
return -EBUSY;
--
2.55.0