|
18 | 18 | #include <linux/fb.h>
|
19 | 19 | #include <linux/slab.h>
|
20 | 20 |
|
| 21 | +static void lcd_notify_blank(struct lcd_device *ld, struct device *display_dev, |
| 22 | + int power) |
| 23 | +{ |
| 24 | + guard(mutex)(&ld->ops_lock); |
| 25 | + |
| 26 | + if (!ld->ops || !ld->ops->set_power) |
| 27 | + return; |
| 28 | + if (ld->ops->controls_device && !ld->ops->controls_device(ld, display_dev)) |
| 29 | + return; |
| 30 | + |
| 31 | + ld->ops->set_power(ld, power); |
| 32 | +} |
| 33 | + |
| 34 | +static void lcd_notify_mode_change(struct lcd_device *ld, struct device *display_dev, |
| 35 | + unsigned int width, unsigned int height) |
| 36 | +{ |
| 37 | + guard(mutex)(&ld->ops_lock); |
| 38 | + |
| 39 | + if (!ld->ops || !ld->ops->set_mode) |
| 40 | + return; |
| 41 | + if (ld->ops->controls_device && !ld->ops->controls_device(ld, display_dev)) |
| 42 | + return; |
| 43 | + |
| 44 | + ld->ops->set_mode(ld, width, height); |
| 45 | +} |
| 46 | + |
21 | 47 | #if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
|
22 | 48 | defined(CONFIG_LCD_CLASS_DEVICE_MODULE))
|
23 | 49 | static int to_lcd_power(int fb_blank)
|
@@ -50,25 +76,17 @@ static int fb_notifier_callback(struct notifier_block *self,
|
50 | 76 | struct fb_info *info = evdata->info;
|
51 | 77 | struct lcd_device *fb_lcd = fb_lcd_device(info);
|
52 | 78 |
|
53 |
| - guard(mutex)(&ld->ops_lock); |
54 |
| - |
55 |
| - if (!ld->ops) |
56 |
| - return 0; |
57 |
| - if (ld->ops->controls_device && !ld->ops->controls_device(ld, info->device)) |
58 |
| - return 0; |
59 | 79 | if (fb_lcd && fb_lcd != ld)
|
60 | 80 | return 0;
|
61 | 81 |
|
62 | 82 | if (event == FB_EVENT_BLANK) {
|
63 | 83 | int power = to_lcd_power(*(int *)evdata->data);
|
64 | 84 |
|
65 |
| - if (ld->ops->set_power) |
66 |
| - ld->ops->set_power(ld, power); |
| 85 | + lcd_notify_blank(ld, info->device, power); |
67 | 86 | } else {
|
68 | 87 | const struct fb_videomode *videomode = evdata->data;
|
69 | 88 |
|
70 |
| - if (ld->ops->set_mode) |
71 |
| - ld->ops->set_mode(ld, videomode->xres, videomode->yres); |
| 89 | + lcd_notify_mode_change(ld, info->device, videomode->xres, videomode->yres); |
72 | 90 | }
|
73 | 91 |
|
74 | 92 | return 0;
|
|
0 commit comments