]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
backlight: lcd: Move event handling into helpers
authorThomas Zimmermann <tzimmermann@suse.de>
Fri, 21 Mar 2025 09:54:00 +0000 (10:54 +0100)
committerLee Jones <lee@kernel.org>
Thu, 10 Apr 2025 09:39:09 +0000 (10:39 +0100)
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@suse.de>
Reviewed-by: "Daniel Thompson (RISCstar)" <danielt@kernel.org>
Acked-by: Simona Vetter <simona.vetter@ffwll.ch>
Link: https://lore.kernel.org/r/20250321095517.313713-8-tzimmermann@suse.de
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/video/backlight/lcd.c

index 3267acf8dc5b12595eb5d79d2f72ba5d10c73041..f57ff8bcc2fa55b4468428c16dc8d0feccbb8a80 100644 (file)
 #include <linux/fb.h>
 #include <linux/slab.h>
 
+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)
@@ -50,25 +76,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;