Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

backlight: lcd: Rearrange code in fb_notifier_callback()

First acquire the ops_lock and do all tests while holding it. Rearranges
the code in lcd's fb_notifier_callback() to resemble the callback in
the backlight module. This will simplify later changes to these tests.

v2:
- avoid gotos by using guard(mutex) (Daniel)
- fix typos in commit description (Daniel)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Link: https://lore.kernel.org/r/20240906075439.98476-2-tzimmermann@suse.de
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Thomas Zimmermann and committed by
Lee Jones
d3687036 9852d85e

+13 -12
+13 -12
drivers/video/backlight/lcd.c
··· 27 27 static int fb_notifier_callback(struct notifier_block *self, 28 28 unsigned long event, void *data) 29 29 { 30 - struct lcd_device *ld; 30 + struct lcd_device *ld = container_of(self, struct lcd_device, fb_notif); 31 31 struct fb_event *evdata = data; 32 + struct fb_info *info = evdata->info; 32 33 33 - ld = container_of(self, struct lcd_device, fb_notif); 34 + guard(mutex)(&ld->ops_lock); 35 + 34 36 if (!ld->ops) 35 37 return 0; 38 + if (ld->ops->check_fb && !ld->ops->check_fb(ld, info)) 39 + return 0; 36 40 37 - mutex_lock(&ld->ops_lock); 38 - if (!ld->ops->check_fb || ld->ops->check_fb(ld, evdata->info)) { 39 - if (event == FB_EVENT_BLANK) { 40 - if (ld->ops->set_power) 41 - ld->ops->set_power(ld, *(int *)evdata->data); 42 - } else { 43 - if (ld->ops->set_mode) 44 - ld->ops->set_mode(ld, evdata->data); 45 - } 41 + if (event == FB_EVENT_BLANK) { 42 + if (ld->ops->set_power) 43 + ld->ops->set_power(ld, *(int *)evdata->data); 44 + } else { 45 + if (ld->ops->set_mode) 46 + ld->ops->set_mode(ld, evdata->data); 46 47 } 47 - mutex_unlock(&ld->ops_lock); 48 + 48 49 return 0; 49 50 } 50 51