Skip to content

Commit 2622825

Browse files
tdzlag-linaro
authored andcommitted
backlight: lcd: Test against struct fb_info.lcd_dev
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 <[email protected]> Reviewed-by: Daniel Thompson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent d368703 commit 2622825

File tree

2 files changed

+16
-0
lines changed
  • drivers/video/backlight
  • include/linux

2 files changed

+16
-0
lines changed

drivers/video/backlight/lcd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ static int fb_notifier_callback(struct notifier_block *self,
3030
struct lcd_device *ld = container_of(self, struct lcd_device, fb_notif);
3131
struct fb_event *evdata = data;
3232
struct fb_info *info = evdata->info;
33+
struct lcd_device *fb_lcd = fb_lcd_device(info);
3334

3435
guard(mutex)(&ld->ops_lock);
3536

3637
if (!ld->ops)
3738
return 0;
3839
if (ld->ops->check_fb && !ld->ops->check_fb(ld, info))
3940
return 0;
41+
if (fb_lcd && fb_lcd != ld)
42+
return 0;
4043

4144
if (event == FB_EVENT_BLANK) {
4245
if (ld->ops->set_power)

include/linux/fb.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct fb_info;
2121
struct file;
2222
struct i2c_adapter;
2323
struct inode;
24+
struct lcd_device;
2425
struct module;
2526
struct notifier_block;
2627
struct page;
@@ -480,6 +481,13 @@ struct fb_info {
480481
struct mutex bl_curve_mutex;
481482
u8 bl_curve[FB_BACKLIGHT_LEVELS];
482483
#endif
484+
485+
/*
486+
* Assigned LCD device; set before framebuffer
487+
* registration, remove after unregister
488+
*/
489+
struct lcd_device *lcd_dev;
490+
483491
#ifdef CONFIG_FB_DEFERRED_IO
484492
struct delayed_work deferred_work;
485493
unsigned long npagerefs;
@@ -754,6 +762,11 @@ static inline struct backlight_device *fb_bl_device(struct fb_info *info)
754762
}
755763
#endif
756764

765+
static inline struct lcd_device *fb_lcd_device(struct fb_info *info)
766+
{
767+
return info->lcd_dev;
768+
}
769+
757770
/* fbmon.c */
758771
#define FB_MAXTIMINGS 0
759772
#define FB_VSYNCTIMINGS 1

0 commit comments

Comments
 (0)