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

Commit 635d2968 authored by Guru Das Srinagesh's avatar Guru Das Srinagesh
Browse files

leds: qti-flash: Enable zero brightness symmetry distribution



Currently, when a single channel's brightness is set, and then cleared
to zero subsequently, the LED stays on instead of getting turned off
because symmetrical brightness distribution logic does not allow the
paired channel's brightness to be set to zero. Fix this.

It was also observed that the brightness of a channel that is getting
turned off doesn't show up as zero, so fix that as well.

In addition, strengthen error-checking of the "qcom,led-mask" device
tree property.

Change-Id: I245ec2177b2ebe0f567eb96397dd13a05a587d60
Signed-off-by: default avatarGuru Das Srinagesh <gurus@codeaurora.org>
parent 568fc7ac
Loading
Loading
Loading
Loading
+7 −12
Original line number Diff line number Diff line
@@ -520,6 +520,8 @@ static int __qti_flash_led_brightness_set(struct led_classdev *led_cdev,
		if (rc < 0)
			pr_err("Failed to disable LED\n");

		led_cdev->brightness = 0;

		return rc;
	}

@@ -563,19 +565,13 @@ static int qti_flash_config_group_symmetry(struct qti_flash_led *led,
		}
	}

	if (!symmetric_leds || !total_curr_ma) {
		pr_debug("Incorrect configuration, symmetric_leds: %d total_curr_ma: %d\n",
			symmetric_leds, total_curr_ma);
		return 0;
	if (!symmetric_leds) {
		pr_err("led-mask %#x has zero symmetric leds\n", led_mask);
		return -EINVAL;
	}

	per_led_curr_ma = total_curr_ma / symmetric_leds;

	if (per_led_curr_ma == 0) {
		pr_warn("per_led_curr_ma cannot be 0\n");
		return 0;
	}

	pr_debug("mask: %#x symmetric_leds: %d total: %d per_led_curr_ma: %d\n",
		led_mask, symmetric_leds, total_curr_ma, per_led_curr_ma);

@@ -1437,9 +1433,8 @@ static int register_switch_device(struct qti_flash_led *led,
		pr_err("Failed to read led mask rc=%d\n", rc);
		return rc;
	}
	if (snode->led_mask > LED_MASK_ALL(led)) {
		pr_err("Error, Invalid value for led-mask mask=0x%x\n",
			snode->led_mask);
	if (!snode->led_mask || snode->led_mask > LED_MASK_ALL(led)) {
		pr_err("led-mask %#x invalid\n", snode->led_mask);
		return -EINVAL;
	} else if (snode->led_mask < LED_MASK_ALL(led)) {
		led->non_all_mask_switch_present = true;