Move the handling of display updates to separate helper functions. There is code for handling fbdev blank events and fbdev mode changes. The code currently runs from fbdev event notifiers, which will be replaced. Signed-off-by: Thomas Zimmermann <tzimmermann@xxxxxxx> --- drivers/video/backlight/lcd.c | 38 ++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c index 95a371b3e8a4..b2ee25060d66 100644 --- a/drivers/video/backlight/lcd.c +++ b/drivers/video/backlight/lcd.c @@ -21,6 +21,32 @@ static struct list_head lcd_dev_list; static struct mutex lcd_dev_list_mutex; +static void lcd_notify_blank(struct lcd_device *ld, struct device *display_dev, + int power) +{ + guard(mutex)(&ld->ops_lock); + + if (!ld->ops || !ld->ops->set_power) + return; + if (ld->ops->controls_device && !ld->ops->controls_device(ld, display_dev)) + return; + + ld->ops->set_power(ld, power); +} + +static void lcd_notify_mode_change(struct lcd_device *ld, struct device *display_dev, + unsigned int width, unsigned int height) +{ + guard(mutex)(&ld->ops_lock); + + if (!ld->ops || !ld->ops->set_mode) + return; + if (ld->ops->controls_device && !ld->ops->controls_device(ld, display_dev)) + return; + + ld->ops->set_mode(ld, width, height); +} + #if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \ defined(CONFIG_LCD_CLASS_DEVICE_MODULE)) static int to_lcd_power(int fb_blank) @@ -53,25 +79,17 @@ static int fb_notifier_callback(struct notifier_block *self, struct fb_info *info = evdata->info; struct lcd_device *fb_lcd = fb_lcd_device(info); - guard(mutex)(&ld->ops_lock); - - if (!ld->ops) - return 0; - if (ld->ops->controls_device && !ld->ops->controls_device(ld, info->device)) - return 0; if (fb_lcd && fb_lcd != ld) return 0; if (event == FB_EVENT_BLANK) { int power = to_lcd_power(*(int *)evdata->data); - if (ld->ops->set_power) - ld->ops->set_power(ld, power); + lcd_notify_blank(ld, info->device, power); } else { const struct fb_videomode *videomode = evdata->data; - if (ld->ops->set_mode) - ld->ops->set_mode(ld, videomode->xres, videomode->yres); + lcd_notify_mode_change(ld, info->device, videomode->xres, videomode->yres); } return 0; -- 2.48.1