Skip to content

Commit d368703

Browse files
tdzlag-linaro
authored andcommitted
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 <[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 9852d85 commit d368703

File tree

1 file changed

+13
-12
lines changed
  • drivers/video/backlight

1 file changed

+13
-12
lines changed

drivers/video/backlight/lcd.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,25 @@
2727
static int fb_notifier_callback(struct notifier_block *self,
2828
unsigned long event, void *data)
2929
{
30-
struct lcd_device *ld;
30+
struct lcd_device *ld = container_of(self, struct lcd_device, fb_notif);
3131
struct fb_event *evdata = data;
32+
struct fb_info *info = evdata->info;
33+
34+
guard(mutex)(&ld->ops_lock);
3235

33-
ld = container_of(self, struct lcd_device, fb_notif);
3436
if (!ld->ops)
3537
return 0;
38+
if (ld->ops->check_fb && !ld->ops->check_fb(ld, info))
39+
return 0;
3640

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);
4647
}
47-
mutex_unlock(&ld->ops_lock);
48+
4849
return 0;
4950
}
5051

0 commit comments

Comments
 (0)