]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
backlight: lcd: Test against struct fb_info.lcd_dev
authorThomas Zimmermann <tzimmermann@suse.de>
Fri, 6 Sep 2024 07:52:16 +0000 (09:52 +0200)
committerLee Jones <lee@kernel.org>
Mon, 30 Sep 2024 15:49:41 +0000 (16:49 +0100)
Add struct fb_info.lcd_dev for fbdev drivers to store a reference to
their lcd device. Update the lcd's fb_notifier_callback() to test for
this field. The lcd module can now detect if an lcd device belongs to
an fbdev device.

This works similar to the bl_dev for backlights and will allow for
the removal of the check_fb callback from several fbdev driver's lcd
devices.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Link: https://lore.kernel.org/r/20240906075439.98476-3-tzimmermann@suse.de
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/video/backlight/lcd.c
include/linux/fb.h

index 2f57d6867d42313d90bdd46b1c81ff00421d36ee..c69407aed29679a4b4b38986c9b61a863e05ef71 100644 (file)
@@ -30,6 +30,7 @@ static int fb_notifier_callback(struct notifier_block *self,
        struct lcd_device *ld = container_of(self, struct lcd_device, fb_notif);
        struct fb_event *evdata = data;
        struct fb_info *info = evdata->info;
+       struct lcd_device *fb_lcd = fb_lcd_device(info);
 
        guard(mutex)(&ld->ops_lock);
 
@@ -37,6 +38,8 @@ static int fb_notifier_callback(struct notifier_block *self,
                return 0;
        if (ld->ops->check_fb && !ld->ops->check_fb(ld, info))
                return 0;
+       if (fb_lcd && fb_lcd != ld)
+               return 0;
 
        if (event == FB_EVENT_BLANK) {
                if (ld->ops->set_power)
index 267b59ead43212dd5bffe6c68df96d1179b14375..5ba187e08cf7596e5e62613e671bca693ad5aa98 100644 (file)
@@ -21,6 +21,7 @@ struct fb_info;
 struct file;
 struct i2c_adapter;
 struct inode;
+struct lcd_device;
 struct module;
 struct notifier_block;
 struct page;
@@ -480,6 +481,13 @@ struct fb_info {
        struct mutex bl_curve_mutex;
        u8 bl_curve[FB_BACKLIGHT_LEVELS];
 #endif
+
+       /*
+        * Assigned LCD device; set before framebuffer
+        * registration, remove after unregister
+        */
+       struct lcd_device *lcd_dev;
+
 #ifdef CONFIG_FB_DEFERRED_IO
        struct delayed_work deferred_work;
        unsigned long npagerefs;
@@ -754,6 +762,11 @@ static inline struct backlight_device *fb_bl_device(struct fb_info *info)
 }
 #endif
 
+static inline struct lcd_device *fb_lcd_device(struct fb_info *info)
+{
+       return info->lcd_dev;
+}
+
 /* fbmon.c */
 #define FB_MAXTIMINGS          0
 #define FB_VSYNCTIMINGS                1