diff options
author | Heiner Kallweit <hkallweit1@gmail.com> | 2024-03-04 21:57:30 +0100 |
---|---|---|
committer | Lee Jones <lee@kernel.org> | 2024-03-28 10:39:49 +0000 |
commit | 822c91e72eac568ed8d83765634f00decb45666c (patch) | |
tree | c13308539d0a65fbf47711eb528d4459e57daaf4 /include/linux/leds.h | |
parent | 4cece764965020c22cff7665b18a012006359095 (diff) | |
download | linux-stable-822c91e72eac568ed8d83765634f00decb45666c.tar.gz linux-stable-822c91e72eac568ed8d83765634f00decb45666c.tar.bz2 linux-stable-822c91e72eac568ed8d83765634f00decb45666c.zip |
leds: trigger: Store brightness set by led_trigger_event()
If a simple trigger is assigned to a LED, then the LED may be off until
the next led_trigger_event() call. This may be an issue for simple
triggers with rare led_trigger_event() calls, e.g. power supply
charging indicators (drivers/power/supply/power_supply_leds.c).
Therefore persist the brightness value of the last led_trigger_event()
call and use this value if the trigger is assigned to a LED.
In addition add a getter for the trigger brightness value.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/b1358b25-3f30-458d-8240-5705ae007a8a@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
Diffstat (limited to 'include/linux/leds.h')
-rw-r--r-- | include/linux/leds.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/leds.h b/include/linux/leds.h index db6b114bb3d9..7964ee38b2a3 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -455,6 +455,9 @@ struct led_trigger { int (*activate)(struct led_classdev *led_cdev); void (*deactivate)(struct led_classdev *led_cdev); + /* Brightness set by led_trigger_event */ + enum led_brightness brightness; + /* LED-private triggers have this set */ struct led_hw_trigger_type *trigger_type; @@ -508,6 +511,12 @@ static inline void *led_get_trigger_data(struct led_classdev *led_cdev) return led_cdev->trigger_data; } +static inline enum led_brightness +led_trigger_get_brightness(const struct led_trigger *trigger) +{ + return trigger ? trigger->brightness : LED_OFF; +} + #define module_led_trigger(__led_trigger) \ module_driver(__led_trigger, led_trigger_register, \ led_trigger_unregister) @@ -544,6 +553,12 @@ static inline void *led_get_trigger_data(struct led_classdev *led_cdev) return NULL; } +static inline enum led_brightness +led_trigger_get_brightness(const struct led_trigger *trigger) +{ + return LED_OFF; +} + #endif /* CONFIG_LEDS_TRIGGERS */ /* Trigger specific enum */ |