Skip to contentSkip to conversation

LCD: fix oops if driver only interested in .set_power

DISCUSSION Ben Dooks 1 participant 1 message Nov 18, 2008 1 message not in the archive Framebuffer layer

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Ben Dooks

author
#1 lore raw
Quoted 19 lines · Ben Dooks

The LCD driver core calls LCD drivers when either the blanking state or the display mode has changed, but does not make any check to see if the called driver has a .set_mode method.

This means if a driver only has a .set_power method then the system will OOPS on changing mode (and with the console semaphore held so you cannot easily see the problem).

Fix the problem by ensuring that either callback is valid before calling it.

Index: linux.git/drivers/video/backlight/lcd.c
===================================================================

drivers/video/backlight/lcd.c static int fb_notifier_callback(struct n · line 48

Quoted 7 lines
drivers/video/backlight/lcd.c +2 -1
@@ -43,9 +43,11 @@ static int fb_notifier_callback(struct n
 	mutex_lock(&ld->ops_lock);
 	if (!ld->ops->check_fb || ld->ops->check_fb(ld, evdata->info)) {
 		if (event == FB_EVENT_BLANK)
-			ld->ops->set_power(ld, *(int *)evdata->data);
+			if (ld->ops->set_power)
+				ld->ops->set_power(ld, *(int *)evdata->data);
 		else

sorry, needed to put {} around the outer if block to keep gcc happy.

Quoted 21 lines
drivers/video/backlight/lcd.c +2 -1
-			ld->ops->set_mode(ld, evdata->data);
+			if (ld->ops->set_mode)
+				ld->ops->set_mode(ld, evdata->data);
 	}
 	mutex_unlock(&ld->ops_lock);
 	return 0;
Signature · 14 lines
-- 
Ben ([email protected], http://www.fluff.org/)

  'a smiley only costs 4 bytes'

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Linux-fbdev-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-fbdev-devel
Signature · 9 lines
Ben ([email protected], http://www.fluff.org/)

  'a smiley only costs 4 bytes'

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/