Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ab808011 authored by Guru Das Srinagesh's avatar Guru Das Srinagesh
Browse files

leds: qti-flash: Support zero duration for flash safety timer



The minimum timeout that can be set is 10 ms due to the clamping being
done in led_set_flash_timeout() in the flash LED class framework. Change
the minimum to allow zero timeout to be set, and also disallow setting
strobe in this case.

Change-Id: Ic34057197c05daf640c2a7d21cbae8e4638319ee
Signed-off-by: default avatarGuru Das Srinagesh <gurus@codeaurora.org>
parent 1a00e832
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -205,8 +205,7 @@ static const u32 flash_led_max_ires_values[MAX_IRES_LEVELS] = {

static int timeout_to_code(u32 timeout)
{
	if (timeout < SAFETY_TIMER_MIN_TIMEOUT_MS ||
		timeout > SAFETY_TIMER_MAX_TIMEOUT_MS)
	if (!timeout || timeout > SAFETY_TIMER_MAX_TIMEOUT_MS)
		return -EINVAL;

	return DIV_ROUND_CLOSEST(timeout, SAFETY_TIMER_STEP_SIZE) - 1;
@@ -1120,6 +1119,11 @@ static int qti_flash_strobe_set(struct led_classdev_flash *fdev,
	if (state && !fnode->configured)
		return -EINVAL;

	if (!fnode->duration) {
		pr_debug("Safety time duration is zero, strobe not set\n");
		return -EINVAL;
	}

	mask = FLASH_LED_ENABLE(fnode->id);
	value = state ? FLASH_LED_ENABLE(fnode->id) : 0;

@@ -1162,6 +1166,11 @@ static int qti_flash_timeout_set(struct led_classdev_flash *fdev,
	fnode = container_of(fdev, struct flash_node_data, fdev);
	led = fnode->led;

	if (!timeout) {
		fnode->duration = 0;
		return 0;
	}

	timeout = timeout / 1000;

	rc = timeout_to_code(timeout);
@@ -1504,7 +1513,7 @@ static int register_flash_device(struct qti_flash_led *led,
	setting->val = default_curr_ma;

	setting = &fnode->fdev.timeout;
	setting->min = SAFETY_TIMER_MIN_TIMEOUT_MS * 1000;
	setting->min = 0;
	setting->max = SAFETY_TIMER_MAX_TIMEOUT_MS * 1000;
	setting->step = SAFETY_TIMER_STEP_SIZE * 1000;
	setting->val = SAFETY_TIMER_DEFAULT_TIMEOUT_MS * 1000;