Re: [PATCH 2/2] leds: tps6131x: clear torch brightness cache on flash takeover
From: Matthias Fend
Date: Thu Nov 19 2026 - 03:10:39 EST
Hi Jie,
Am 17.11.2026 um 07:43 schrieb jiegu:
From: gujie <jie.gu@xxxxxxxxxxxxxxxxxxxxxxx>
When the device switches from torch mode to flash or external strobe
mode, the hardware torch output is disabled, but the LED class
brightness cache may still keep the previous non-zero torch value.
This leaves sysfs brightness reporting an enabled torch state even
though the light is already off.
Update the cached LED brightness to LED_OFF when flash control takes
over so userspace state matches the actual hardware state.
Signed-off-by: gujie <jie.gu@xxxxxxxxxxxxxxxxxxxxxxx>
---
drivers/leds/flash/leds-tps6131x.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/leds/flash/leds-tps6131x.c b/drivers/leds/flash/leds-tps6131x.c
index 823e0462939c..4f708cf56178 100644
--- a/drivers/leds/flash/leds-tps6131x.c
+++ b/drivers/leds/flash/leds-tps6131x.c
@@ -294,6 +294,11 @@ static int tps6131x_set_mode(struct tps6131x *tps6131x, enum tps6131x_mode mode,
NULL, false, force);
}
+static void tps6131x_sync_torch_brightness_off(struct tps6131x *tps6131x)
+{
+ tps6131x->fled_cdev.led_cdev.brightness = LED_OFF;
+}
Nit: I don't think that we need a helper for this one-liner. But also okay for me.
Tested with i.MX8MP-EVK and TPS61310EVM.
Reviewed-by: Matthias Fend <matthias.fend@xxxxxxxxx>
Tested-by: Matthias Fend <matthias.fend@xxxxxxxxx>
Best regards
~Matthias