summaryrefslogtreecommitdiff
path: root/drivers/leds
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2025-03-21 10:54:02 +0100
committerLee Jones <lee@kernel.org>2025-04-10 10:39:12 +0100
commit28f8bab711c0984005a6dd4cc980b4ba8409b817 (patch)
tree24a0f2b52d82d401633bbe9c428d8e4d566d8c2e /drivers/leds
parentbc70cc84f5a2ebfd7e7112e9b8837e0c7954fc65 (diff)
leds: backlight trigger: Move blank-state handling into helper
Move the handling of blank-state updates into a separate helper, so that is can be called without the fbdev event. No functional changes. v2: - rename helper to avoid renaming in a later patch (Lee) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Acked-by: Simona Vetter <simona.vetter@ffwll.ch> Link: https://lore.kernel.org/r/20250321095517.313713-10-tzimmermann@suse.de Signed-off-by: Lee Jones <lee@kernel.org>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/trigger/ledtrig-backlight.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/drivers/leds/trigger/ledtrig-backlight.c b/drivers/leds/trigger/ledtrig-backlight.c
index 487577d22cfc6..8e66d55a6c824 100644
--- a/drivers/leds/trigger/ledtrig-backlight.c
+++ b/drivers/leds/trigger/ledtrig-backlight.c
@@ -25,12 +25,28 @@ struct bl_trig_notifier {
unsigned invert;
};
+static void ledtrig_backlight_notify_blank(struct bl_trig_notifier *n, int new_status)
+{
+ struct led_classdev *led = n->led;
+
+ if (new_status == n->old_status)
+ return;
+
+ if ((n->old_status == UNBLANK) ^ n->invert) {
+ n->brightness = led->brightness;
+ led_set_brightness_nosleep(led, LED_OFF);
+ } else {
+ led_set_brightness_nosleep(led, n->brightness);
+ }
+
+ n->old_status = new_status;
+}
+
static int fb_notifier_callback(struct notifier_block *p,
unsigned long event, void *data)
{
struct bl_trig_notifier *n = container_of(p,
struct bl_trig_notifier, notifier);
- struct led_classdev *led = n->led;
struct fb_event *fb_event = data;
int *blank;
int new_status;
@@ -42,17 +58,7 @@ static int fb_notifier_callback(struct notifier_block *p,
blank = fb_event->data;
new_status = *blank ? BLANK : UNBLANK;
- if (new_status == n->old_status)
- return 0;
-
- if ((n->old_status == UNBLANK) ^ n->invert) {
- n->brightness = led->brightness;
- led_set_brightness_nosleep(led, LED_OFF);
- } else {
- led_set_brightness_nosleep(led, n->brightness);
- }
-
- n->old_status = new_status;
+ ledtrig_backlight_notify_blank(n, new_status);
return 0;
}