Skip to contentSkip to conversation

power: supply: leds: Fix blink to LED on transition

PATCH In review Hans de Goede 3 participants 3 messages Apr 13, 2023 – May 8, 2023 Power supply

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 power: supply: leds: Fix blink to LED on transition

When a battery's status changes from charging to full then the charging-blink-full-solid trigger tries to change the LED from blinking to solid/on.

As is documented in include/linux/leds.h to deactivate blinking / to make the LED solid a LED_OFF must be send:

"""
* Deactivate blinking again when the brightness is set to LED_OFF
* via the brightness_set() callback.
"""

led_set_brighness() calls with a brightness value other then 0 / LED_OFF merely change the brightness of the LED in its on state while it is blinking.

So power_supply_update_bat_leds() must first send a LED_OFF event before the LED_FULL to disable blinking.

Fixes 6501f728c56f ("power_supply: Add new LED trigger charging-blink-solid-full")
Cc Vasily Khoruzhick <[email protected]>
---
 drivers/power/supply/power_supply_leds.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/power/supply/power_supply_leds.c +3 -2
index e2f554e4e4e6..c7db29d5fcb8 100644
@@ -33,8 +33,9 @@ static void power_supply_update_bat_leds(struct power_supply *psy)
 		led_trigger_event(psy->charging_full_trig, LED_FULL);
 		led_trigger_event(psy->charging_trig, LED_OFF);
 		led_trigger_event(psy->full_trig, LED_FULL);
-		led_trigger_event(psy->charging_blink_full_solid_trig,
-			LED_FULL);
+		/* Going from blink to LED on requires a LED_OFF event to stop blink */
+		led_trigger_event(psy->charging_blink_full_solid_trig, LED_OFF);
+		led_trigger_event(psy->charging_blink_full_solid_trig, LED_FULL);
 		break;
 	case POWER_SUPPLY_STATUS_CHARGING:
 		led_trigger_event(psy->charging_full_trig, LED_FULL);
Signature · 1 line
2.39.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Hans de Goede

When a battery's status changes from charging to full then the charging-blink-full-solid trigger tries to change the LED from blinking to solid/on.

As is documented in include/linux/leds.h to deactivate blinking / to make the LED solid a LED_OFF must be send:

"""
* Deactivate blinking again when the brightness is set to LED_OFF
* via the brightness_set() callback.
"""

Quoted 8 lines

led_set_brighness() calls with a brightness value other then 0 / LED_OFF merely change the brightness of the LED in its on state while it is blinking.

So power_supply_update_bat_leds() must first send a LED_OFF event before the LED_FULL to disable blinking.

Fixes 6501f728c56f ("power_supply: Add new LED trigger charging-blink-solid-full")

Wow, it's a commit from 2011 :)

Quoted 2 lines
Cc Vasily Khoruzhick <[email protected]>
Quoted 23 lines
---
 drivers/power/supply/power_supply_leds.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/power/supply/power_supply_leds.c +3 -3
index e2f554e4e4e6..c7db29d5fcb8 100644
@@ -33,8 +33,9 @@ static void power_supply_update_bat_leds(struct power_supply *psy)
                led_trigger_event(psy->charging_full_trig, LED_FULL);
                led_trigger_event(psy->charging_trig, LED_OFF);
                led_trigger_event(psy->full_trig, LED_FULL);
-               led_trigger_event(psy->charging_blink_full_solid_trig,
-                       LED_FULL);
+               /* Going from blink to LED on requires a LED_OFF event to stop blink */
+               led_trigger_event(psy->charging_blink_full_solid_trig, LED_OFF);
+               led_trigger_event(psy->charging_blink_full_solid_trig, LED_FULL);
                break;
        case POWER_SUPPLY_STATUS_CHARGING:
                led_trigger_event(psy->charging_full_trig, LED_FULL);
--

2.39.1

#2 lore raw

Hi,

Quoted 21 lines · Vasily Khoruzhick
Quoted 20 lines · Hans de Goede

When a battery's status changes from charging to full then the charging-blink-full-solid trigger tries to change the LED from blinking to solid/on.

As is documented in include/linux/leds.h to deactivate blinking / to make the LED solid a LED_OFF must be send:

"""
* Deactivate blinking again when the brightness is set to LED_OFF
* via the brightness_set() callback.
"""

led_set_brighness() calls with a brightness value other then 0 / LED_OFF merely change the brightness of the LED in its on state while it is blinking.

So power_supply_update_bat_leds() must first send a LED_OFF event before the LED_FULL to disable blinking.

Quoted 8 lines
Quoted 1 line
Fixes 6501f728c56f ("power_supply: Add new LED trigger charging-blink-solid-full")

Wow, it's a commit from 2011 :)

Quoted 2 lines
Cc Vasily Khoruzhick <[email protected]>

Thanks, queued to my fixes branch.

-- Sebastian

Quoted 23 lines
Quoted 23 lines
---
 drivers/power/supply/power_supply_leds.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/power/supply/power_supply_leds.c +3 -3
index e2f554e4e4e6..c7db29d5fcb8 100644
@@ -33,8 +33,9 @@ static void power_supply_update_bat_leds(struct power_supply *psy)
                led_trigger_event(psy->charging_full_trig, LED_FULL);
                led_trigger_event(psy->charging_trig, LED_OFF);
                led_trigger_event(psy->full_trig, LED_FULL);
-               led_trigger_event(psy->charging_blink_full_solid_trig,
-                       LED_FULL);
+               /* Going from blink to LED on requires a LED_OFF event to stop blink */
+               led_trigger_event(psy->charging_blink_full_solid_trig, LED_OFF);
+               led_trigger_event(psy->charging_blink_full_solid_trig, LED_FULL);
                break;
        case POWER_SUPPLY_STATUS_CHARGING:
                led_trigger_event(psy->charging_full_trig, LED_FULL);
--

2.39.1