Skip to content

Commit 28f8bab

Browse files
Thomas Zimmermannlag-linaro
authored andcommitted
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>
1 parent bc70cc8 commit 28f8bab

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

drivers/leds/trigger/ledtrig-backlight.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,28 @@ struct bl_trig_notifier {
2525
unsigned invert;
2626
};
2727

28+
static void ledtrig_backlight_notify_blank(struct bl_trig_notifier *n, int new_status)
29+
{
30+
struct led_classdev *led = n->led;
31+
32+
if (new_status == n->old_status)
33+
return;
34+
35+
if ((n->old_status == UNBLANK) ^ n->invert) {
36+
n->brightness = led->brightness;
37+
led_set_brightness_nosleep(led, LED_OFF);
38+
} else {
39+
led_set_brightness_nosleep(led, n->brightness);
40+
}
41+
42+
n->old_status = new_status;
43+
}
44+
2845
static int fb_notifier_callback(struct notifier_block *p,
2946
unsigned long event, void *data)
3047
{
3148
struct bl_trig_notifier *n = container_of(p,
3249
struct bl_trig_notifier, notifier);
33-
struct led_classdev *led = n->led;
3450
struct fb_event *fb_event = data;
3551
int *blank;
3652
int new_status;
@@ -42,17 +58,7 @@ static int fb_notifier_callback(struct notifier_block *p,
4258
blank = fb_event->data;
4359
new_status = *blank ? BLANK : UNBLANK;
4460

45-
if (new_status == n->old_status)
46-
return 0;
47-
48-
if ((n->old_status == UNBLANK) ^ n->invert) {
49-
n->brightness = led->brightness;
50-
led_set_brightness_nosleep(led, LED_OFF);
51-
} else {
52-
led_set_brightness_nosleep(led, n->brightness);
53-
}
54-
55-
n->old_status = new_status;
61+
ledtrig_backlight_notify_blank(n, new_status);
5662

5763
return 0;
5864
}

0 commit comments

Comments
 (0)