Skip to content

Commit fd05e36

Browse files
ChiaEn Wulag-linaro
authored andcommitted
leds: mt6360: Fix the second LED can not enable torch mode by V4L2
V4L2 will disable strobe mode of the LED device when enable torch mode, but this logic will conflict with the "priv->fled_torch_used" in "mt6360_strobe_set()". So after enabling torch mode of the first LED, the second LED will not be able to enable torch mode correctly. Therefore, at the beginning of "mt6360_strobe_set()", check whether the state of the upcoming change and the current LED device state are the same, so as to avoid the above problem. Signed-off-by: ChiaEn Wu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent fc3b23f commit fd05e36

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/leds/flash/leds-mt6360.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,20 @@ static int mt6360_strobe_set(struct led_classdev_flash *fl_cdev, bool state)
241241
u32 enable_mask = MT6360_STROBEN_MASK | MT6360_FLCSEN_MASK(led->led_no);
242242
u32 val = state ? MT6360_FLCSEN_MASK(led->led_no) : 0;
243243
u32 prev = priv->fled_strobe_used, curr;
244-
int ret;
244+
int ret = 0;
245245

246246
mutex_lock(&priv->lock);
247247

248+
/*
249+
* If the state of the upcoming change is the same as the current LED
250+
* device state, then skip the subsequent code to avoid conflict
251+
* with the flow of turning on LED torch mode in V4L2.
252+
*/
253+
if (state == !!(BIT(led->led_no) & prev)) {
254+
dev_info(lcdev->dev, "No change in strobe state [0x%x]\n", prev);
255+
goto unlock;
256+
}
257+
248258
/*
249259
* Only one set of flash control logic, use the flag to avoid torch is
250260
* currently used

0 commit comments

Comments
 (0)