diff mbox series

[v3,5/5] leds: cht-wcove: Use breathing when LED_INIT_DEFAULT_TRIGGER is set

Message ID 20230430195952.862527-6-hdegoede@redhat.com
State New
Headers show
Series leds: Add Intel Cherry Trail Whiskey Cove PMIC LED driver | expand

Commit Message

Hans de Goede April 30, 2023, 7:59 p.m. UTC
The desired default behavior of LED1 / the charge LED is breathing
while charging and on/solid when full. Since triggers cannot select
breathing, blink_set() gets called when charging. Use breathing
when the default "charging-blink-full-solid" trigger is used to
achieve the desired default behavior.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v3:
- Also set on/off delay to 1000 so that we get a slow breathing effect,
  this counter-acts the v2 cht_wc_leds_set_effect() change changing
  the default delays from 1000 to 500
---
 drivers/leds/leds-cht-wcove.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

Comments

Lee Jones May 15, 2023, 3:07 p.m. UTC | #1
On Sun, 30 Apr 2023, Hans de Goede wrote:

> The desired default behavior of LED1 / the charge LED is breathing
> while charging and on/solid when full. Since triggers cannot select
> breathing, blink_set() gets called when charging. Use breathing
> when the default "charging-blink-full-solid" trigger is used to
> achieve the desired default behavior.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> Changes in v3:
> - Also set on/off delay to 1000 so that we get a slow breathing effect,
>   this counter-acts the v2 cht_wc_leds_set_effect() change changing
>   the default delays from 1000 to 500
> ---
>  drivers/leds/leds-cht-wcove.c | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)

Applied, thanks
diff mbox series

Patch

diff --git a/drivers/leds/leds-cht-wcove.c b/drivers/leds/leds-cht-wcove.c
index ee9fb4bee018..0cfebee98910 100644
--- a/drivers/leds/leds-cht-wcove.c
+++ b/drivers/leds/leds-cht-wcove.c
@@ -270,7 +270,21 @@  static int cht_wc_leds_blink_set(struct led_classdev *cdev,
 				 unsigned long *delay_on,
 				 unsigned long *delay_off)
 {
-	return cht_wc_leds_set_effect(cdev, delay_on, delay_off, CHT_WC_LED_EFF_BLINKING);
+	u8 effect = CHT_WC_LED_EFF_BLINKING;
+
+	/*
+	 * The desired default behavior of LED1 / the charge LED is breathing
+	 * while charging and on/solid when full. Since triggers cannot select
+	 * breathing, blink_set() gets called when charging. Use slow breathing
+	 * when the default "charging-blink-full-solid" trigger is used to
+	 * achieve the desired default behavior.
+	 */
+	if (cdev->flags & LED_INIT_DEFAULT_TRIGGER) {
+		*delay_on = *delay_off = 1000;
+		effect = CHT_WC_LED_EFF_BREATHING;
+	}
+
+	return cht_wc_leds_set_effect(cdev, delay_on, delay_off, effect);
 }
 
 static int cht_wc_leds_pattern_set(struct led_classdev *cdev,