Move the handling of blank-state updates into a separate helper, so that is can be called without the fbdev event. No functional changes. Signed-off-by: Thomas Zimmermann <tzimmermann@xxxxxxx> --- drivers/leds/trigger/ledtrig-backlight.c | 33 ++++++++++++++---------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/drivers/leds/trigger/ledtrig-backlight.c b/drivers/leds/trigger/ledtrig-backlight.c index c1c1aa60cf07..f9317f93483b 100644 --- a/drivers/leds/trigger/ledtrig-backlight.c +++ b/drivers/leds/trigger/ledtrig-backlight.c @@ -30,34 +30,39 @@ struct bl_trig_notifier { static struct list_head ledtrig_backlight_list; static struct mutex ledtrig_backlight_list_mutex; +static void ledtrig_backlight_blank(struct bl_trig_notifier *n, bool on) +{ + struct led_classdev *led = n->led; + int new_status = !on ? BLANK : UNBLANK; + + 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; /* If we aren't interested in this event, skip it immediately ... */ if (event != FB_EVENT_BLANK) return 0; 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_blank(n, !blank[0]); return 0; } -- 2.48.1