diff mbox series

leds: led-core: The value of delay_on and delay_off remains when led off

Message ID 20210429125908.8308-1-lqhua06@163.com
State New
Headers show
Series leds: led-core: The value of delay_on and delay_off remains when led off | expand

Commit Message

lqhua06@163.com April 29, 2021, 12:59 p.m. UTC
From: "quanah.li_cp" <liqinghua@yulong.com>

The LED connect to pmic gpio, and the LED can blinking during
AP goto sleep.

When the LED is turned off and the hardware blinking will be disabled,
but the value of delay_on and delay_off still remains.

Signed-off-by: quanah.li_cp <liqinghua@yulong.com>
---
 drivers/leds/led-core.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Pavel Machek Aug. 4, 2021, 4:13 p.m. UTC | #1
On Thu 2021-04-29 20:59:08, lqhua06@163.com wrote:
> From: "quanah.li_cp" <liqinghua@yulong.com>

> 

> The LED connect to pmic gpio, and the LED can blinking during

> AP goto sleep.

> 

> When the LED is turned off and the hardware blinking will be disabled,

> but the value of delay_on and delay_off still remains.


Is that a problem?

It seems this is a feature, not a bug.

Best regards,
								Pavel
-- 
http://www.livejournal.com/~pavelmachek
diff mbox series

Patch

diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index 8eb8054..5db251d 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -262,6 +262,19 @@  void led_set_brightness(struct led_classdev *led_cdev, unsigned int brightness)
 	}
 
 	led_set_brightness_nosleep(led_cdev, brightness);
+
+	/* When the LED is off and the hardware blinking will be disabled,
+	 * but the value of delay_on and delay_off still remains.
+	 */
+	if ((led_cdev->blink_delay_off > 0) &&
+		(led_cdev->blink_delay_on > 0) &&
+		(brightness == LED_OFF)) {
+		if (!test_bit(LED_BLINK_ONESHOT, &led_cdev->work_flags) &&
+			led_cdev->blink_set) {
+			led_cdev->blink_delay_on = 0;
+			led_cdev->blink_delay_off = 0;
+		}
+	}
 }
 EXPORT_SYMBOL_GPL(led_set_brightness);