From 3fa44c01e4da72819d49193137bc48b335c3229b Mon Sep 17 00:00:00 2001 From: Subbaraman Narayanamurthy Date: Tue, 21 Jun 2022 14:15:47 -0700 Subject: [PATCH] leds: qti-flash: set switch enabled state for precision control properly Currently, for precision flash control, switch device's enabled state is set to true when the brightness is set to 1 and on_timer is started. However, it can be set to false only when the brightness is set to 0. For camera flash use cases like turning on pre-flash/torch immediately following the timed flash event, this needs to be changed i.e. set the enabled state to false when the off_timer callback is invoked to disable switch device. Change-Id: Ib99ef1e93a21645a816555cc44c66957b5d2a43b Suggested-by: Depeng Shao Signed-off-by: Subbaraman Narayanamurthy --- drivers/leds/leds-qti-flash.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/leds/leds-qti-flash.c b/drivers/leds/leds-qti-flash.c index 95b941d5d199..38dae2f74dd8 100644 --- a/drivers/leds/leds-qti-flash.c +++ b/drivers/leds/leds-qti-flash.c @@ -799,7 +799,6 @@ static void qti_flash_led_switch_brightness_set( hrtimer_start(&snode->on_timer, ms_to_ktime(snode->on_time_ms), HRTIMER_MODE_REL); - snode->enabled = state; return; } @@ -841,6 +840,8 @@ static enum hrtimer_restart off_timer_function(struct hrtimer *timer) if (rc < 0) pr_err("Failed to disable flash LED switch %s, rc=%d\n", snode->cdev.name, rc); + else + snode->enabled = false; return HRTIMER_NORESTART; } @@ -856,6 +857,8 @@ static enum hrtimer_restart on_timer_function(struct hrtimer *timer) snode->enabled = false; pr_err("Failed to enable flash LED switch %s, rc=%d\n", snode->cdev.name, rc); + } else { + snode->enabled = true; } return HRTIMER_NORESTART;