LCD: fix oops if driver only interested in .set_power

From: Ben Dooks <ben-linux@fluff.org>
Date: 2008-11-18 18:31:16

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 use.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux.git/drivers/video/backlight/lcd.c
===================================================================
--- linux.git.orig/drivers/video/backlight/lcd.c	2008-11-18 15:07:37.000000000 +0000
+++ linux.git/drivers/video/backlight/lcd.c	2008-11-18 15:08:18.000000000 +0000
@@ -42,10 +42,13 @@ 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);
-		else
-			ld->ops->set_mode(ld, evdata->data);
+		if (event == FB_EVENT_BLANK) {
+			if (ld->ops->set_power)
+				ld->ops->set_power(ld, *(int *)evdata->data);
+		} else {
+			if (ld->ops->set_mode)
+				ld->ops->set_mode(ld, evdata->data);
+		}
 	}
 	mutex_unlock(&ld->ops_lock);
 	return 0;
-- 
Ben (ben@fluff.org, 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=/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help