leds: add flag to keep trigger always

Commit 0013b23d66 ("leds: disable
triggers on brightness set") removes the trigger on a LED class
device when brightness is set to 0. However, there are some LED
class devices which needs the trigger not to be removed. In an
use case like camera flash, camera flash driver passes in a
trigger device to LED class driver. If the trigger is removed
when the brightness is set to 0, this will affect the clients
using those triggers. Hence add a flag to always keep the trigger
even when brightness is set to 0.

Change-Id: Icec1380b297bc87058ea5024ef690ee3c1bed9e3
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
This commit is contained in:
Subbaraman Narayanamurthy 2017-01-04 18:46:48 -08:00
parent 9c431a0ce3
commit b827b53c3c
2 changed files with 2 additions and 1 deletions

View file

@ -54,7 +54,7 @@ static ssize_t brightness_store(struct device *dev,
if (ret)
goto unlock;
if (state == LED_OFF)
if (state == LED_OFF && !(led_cdev->flags & LED_KEEP_TRIGGER))
led_trigger_remove(led_cdev);
led_set_brightness(led_cdev, state);

View file

@ -50,6 +50,7 @@ struct led_classdev {
#define LED_PANIC_INDICATOR BIT(20)
#define LED_BRIGHT_HW_CHANGED BIT(21)
#define LED_RETAIN_AT_SHUTDOWN BIT(22)
#define LED_KEEP_TRIGGER BIT(23)
/* set_brightness_work / blink_timer flags, atomic, private. */
unsigned long work_flags;