mirror of
https://github.com/torvalds/linux.git
synced 2026-08-02 05:12:01 +02:00
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: Guru Das Srinagesh <gurus@codeaurora.org>
This commit is contained in:
parent
fb86d87aa8
commit
e713399a51
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user