]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
leds: trigger: tty: Do not use LED_ON/OFF constants, use led_blink_set_oneshot instead
authorMarek Behún <kabel@kernel.org>
Wed, 2 Aug 2023 09:07:53 +0000 (11:07 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Sep 2023 10:22:49 +0000 (12:22 +0200)
commit8869fd166f23bd594f05b890f53932776cd8f272
tree3bc4bdd95488db9645b0a285f014cb04e09888fa
parent0f715ea7d36e2582ad5bd4b4ddd24f3fd45d13ba
leds: trigger: tty: Do not use LED_ON/OFF constants, use led_blink_set_oneshot instead

[ Upstream commit 730094577e0c37e1bc40be37cbd41f71b0a8a2a4 ]

The tty LED trigger uses the obsolete LED_ON & LED_OFF constants when
setting LED brightness. This is bad because the LED_ON constant is equal
to 1, and so when activating the tty LED trigger on a LED class device
with max_brightness greater than 1, the LED is dimmer than it can be
(when max_brightness is 255, the LED is very dimm indeed; some devices
translate 1/255 to 0, so the LED is OFF all the time).

Instead of directly setting brightness to a specific value, use the
led_blink_set_oneshot() function from LED core to configure the blink.
This function takes the current configured brightness as blink
brightness if not zero, and max brightness otherwise.

This also changes the behavior of the TTY LED trigger. Previously if
rx/tx stats kept changing, the LED was ON all the time they kept
changing. With this patch the LED will blink on TTY activity.

Fixes: fd4a641ac88f ("leds: trigger: implement a tty trigger")
Signed-off-by: Marek Behún <kabel@kernel.org>
Link: https://lore.kernel.org/r/20230802090753.13611-1-kabel@kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/leds/trigger/ledtrig-tty.c