[PATCH 1/2] leds: tps6131x: cancel torch refresh on flash mode switch
From: jiegu
Date: Tue Nov 17 2026 - 01:44:07 EST
From: gujie <jie.gu@xxxxxxxxxxxxxxxxxxxxxxx>
The TPS6131X torch mode uses a delayed work item to refresh the watchdog
timer and keep torch mode active when driven over I2C. If userspace enables
torch and then the camera stack switches the LED into flash or external
strobe mode, the pending refresh work can still run later and force the
device back into torch mode.
Cancel the pending torch refresh work before switching into flash mode from
both the LED flash class strobe path and the V4L2 external strobe path.
Signed-off-by: gujie <jie.gu@xxxxxxxxxxxxxxxxxxxxxxx>
---
drivers/leds/flash/leds-tps6131x.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/leds/flash/leds-tps6131x.c b/drivers/leds/flash/leds-tps6131x.c
index 5c9a5af5af05..823e0462939c 100644
--- a/drivers/leds/flash/leds-tps6131x.c
+++ b/drivers/leds/flash/leds-tps6131x.c
@@ -378,6 +378,7 @@ static int tps6131x_strobe_set(struct led_classdev_flash *fled_cdev, bool state)
struct tps6131x *tps6131x = fled_cdev_to_tps6131x(fled_cdev);
int ret;
+ cancel_delayed_work_sync(&tps6131x->torch_refresh_work);
guard(mutex)(&tps6131x->lock);
ret = tps6131x_set_mode(tps6131x, state ? TPS6131X_MODE_FLASH : TPS6131X_MODE_SHUTDOWN,
@@ -697,6 +698,7 @@ static int tps6131x_flash_external_strobe_set(struct v4l2_flash *v4l2_flash, boo
struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev;
struct tps6131x *tps6131x = fled_cdev_to_tps6131x(fled_cdev);
+ cancel_delayed_work_sync(&tps6131x->torch_refresh_work);
guard(mutex)(&tps6131x->lock);
return tps6131x_set_mode(tps6131x, enable ? TPS6131X_MODE_FLASH : TPS6131X_MODE_SHUTDOWN,
--
2.43.0