diff options
author | Richard Purdie <rpurdie@rpsys.net> | 2007-02-08 22:25:09 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@rpsys.net> | 2007-02-20 08:38:45 +0000 |
commit | 28ee086d5b36aab2931f6740e409bb0fb6c65e5f (patch) | |
tree | 0a308c80affcc39c2c869f29f1109e5ee9d6140f /drivers | |
parent | a8db3c1948eb30cd6988b5b96b654f591e6280b1 (diff) |
backlight: Fix external uses of backlight internal semaphore
backlight_device->sem has a very specific use as documented in the
header file. The external users of this are using it for a different
reason, to serialise access to the update_status() method.
backlight users were supposed to implement their own internal
serialisation of update_status() if needed but everyone is doing
things differently and incorrectly. Therefore add a global mutex to
take care of serialisation for everyone, once and for all.
Locking for get_brightness remains optional since most users don't
need it.
Also update the lcd class in a similar way.
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/macintosh/via-pmu-backlight.c | 4 | ||||
-rw-r--r-- | drivers/misc/asus-laptop.c | 20 | ||||
-rw-r--r-- | drivers/usb/misc/appledisplay.c | 6 | ||||
-rw-r--r-- | drivers/video/aty/aty128fb.c | 6 | ||||
-rw-r--r-- | drivers/video/aty/atyfb_base.c | 6 | ||||
-rw-r--r-- | drivers/video/aty/radeon_backlight.c | 4 | ||||
-rw-r--r-- | drivers/video/backlight/backlight.c | 10 | ||||
-rw-r--r-- | drivers/video/backlight/lcd.c | 1 | ||||
-rw-r--r-- | drivers/video/chipsfb.c | 8 | ||||
-rw-r--r-- | drivers/video/nvidia/nv_backlight.c | 6 | ||||
-rw-r--r-- | drivers/video/riva/fbdev.c | 6 |
11 files changed, 18 insertions, 59 deletions
diff --git a/drivers/macintosh/via-pmu-backlight.c b/drivers/macintosh/via-pmu-backlight.c index db8bcc35bc03..7ba2042b2dd0 100644 --- a/drivers/macintosh/via-pmu-backlight.c +++ b/drivers/macintosh/via-pmu-backlight.c @@ -166,11 +166,9 @@ void __init pmu_backlight_init() pmu_backlight_data.max_brightness / 15); } - down(&bd->sem); bd->props->brightness = level; bd->props->power = FB_BLANK_UNBLANK; - bd->props->update_status(bd); - up(&bd->sem); + backlight_update_status(bd); mutex_lock(&pmac_backlight_mutex); if (!pmac_backlight) diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c index d15ee5e34201..7ace5b9a3d28 100644 --- a/drivers/misc/asus-laptop.c +++ b/drivers/misc/asus-laptop.c @@ -348,13 +348,8 @@ static void lcd_blank(int blank) struct backlight_device *bd = asus_backlight_device; if (bd) { - down(&bd->sem); - if (likely(bd->props)) { - bd->props->power = blank; - if (likely(bd->props->update_status)) - bd->props->update_status(bd); - } - up(&bd->sem); + bd->props->power = blank; + backlight_update_status(bd); } } @@ -1028,14 +1023,9 @@ static int asus_backlight_init(struct device *dev) asus_backlight_device = bd; - down(&bd->sem); - if (likely(bd->props)) { - bd->props->brightness = read_brightness(NULL); - bd->props->power = FB_BLANK_UNBLANK; - if (likely(bd->props->update_status)) - bd->props->update_status(bd); - } - up(&bd->sem); + bd->props->brightness = read_brightness(NULL); + bd->props->power = FB_BLANK_UNBLANK; + backlight_update_status(bd); } return 0; } diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c index 416cde5893af..cd2c5574cf93 100644 --- a/drivers/usb/misc/appledisplay.c +++ b/drivers/usb/misc/appledisplay.c @@ -189,11 +189,9 @@ static void appledisplay_work(struct work_struct *work) container_of(work, struct appledisplay, work.work); int retval; - up(&pdata->bd->sem); retval = appledisplay_bl_get_brightness(pdata->bd); if (retval >= 0) pdata->bd->props->brightness = retval; - down(&pdata->bd->sem); /* Poll again in about 125ms if there's still a button pressed */ if (pdata->button_pressed) @@ -288,9 +286,7 @@ static int appledisplay_probe(struct usb_interface *iface, } /* Try to get brightness */ - up(&pdata->bd->sem); brightness = appledisplay_bl_get_brightness(pdata->bd); - down(&pdata->bd->sem); if (brightness < 0) { retval = brightness; @@ -299,9 +295,7 @@ static int appledisplay_probe(struct usb_interface *iface, } /* Set brightness in backlight device */ - up(&pdata->bd->sem); pdata->bd->props->brightness = brightness; - down(&pdata->bd->sem); /* save our data pointer in the interface device */ usb_set_intfdata(iface, pdata); diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c index 1fa211c0d7bb..5d8f73b2b66f 100644 --- a/drivers/video/aty/aty128fb.c +++ b/drivers/video/aty/aty128fb.c @@ -1807,10 +1807,8 @@ static void aty128_bl_set_power(struct fb_info *info, int power) mutex_lock(&info->bl_mutex); if (info->bl_dev) { - down(&info->bl_dev->sem); info->bl_dev->props->power = power; __aty128_bl_update_status(info->bl_dev); - up(&info->bl_dev->sem); } mutex_unlock(&info->bl_mutex); @@ -1847,11 +1845,9 @@ static void aty128_bl_init(struct aty128fb_par *par) 219 * FB_BACKLIGHT_MAX / MAX_LEVEL); mutex_unlock(&info->bl_mutex); - down(&bd->sem); bd->props->brightness = aty128_bl_data.max_brightness; bd->props->power = FB_BLANK_UNBLANK; - bd->props->update_status(bd); - up(&bd->sem); + backlight_update_status(bd); #ifdef CONFIG_PMAC_BACKLIGHT mutex_lock(&pmac_backlight_mutex); diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c index 5ea5a00e58a3..23deb3566020 100644 --- a/drivers/video/aty/atyfb_base.c +++ b/drivers/video/aty/atyfb_base.c @@ -2188,10 +2188,8 @@ static void aty_bl_set_power(struct fb_info *info, int power) mutex_lock(&info->bl_mutex); if (info->bl_dev) { - down(&info->bl_dev->sem); info->bl_dev->props->power = power; __aty_bl_update_status(info->bl_dev); - up(&info->bl_dev->sem); } mutex_unlock(&info->bl_mutex); @@ -2224,11 +2222,9 @@ static void aty_bl_init(struct atyfb_par *par) 0xFF * FB_BACKLIGHT_MAX / MAX_LEVEL); mutex_unlock(&info->bl_mutex); - down(&bd->sem); bd->props->brightness = aty_bl_data.max_brightness; bd->props->power = FB_BLANK_UNBLANK; - bd->props->update_status(bd); - up(&bd->sem); + backlight_update_status(bd); #ifdef CONFIG_PMAC_BACKLIGHT mutex_lock(&pmac_backlight_mutex); diff --git a/drivers/video/aty/radeon_backlight.c b/drivers/video/aty/radeon_backlight.c index 8b66df6f199a..9cfcecac8b5e 100644 --- a/drivers/video/aty/radeon_backlight.c +++ b/drivers/video/aty/radeon_backlight.c @@ -194,11 +194,9 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo) 217 * FB_BACKLIGHT_MAX / MAX_RADEON_LEVEL); mutex_unlock(&rinfo->info->bl_mutex); - down(&bd->sem); bd->props->brightness = radeon_bl_data.max_brightness; bd->props->power = FB_BLANK_UNBLANK; - bd->props->update_status(bd); - up(&bd->sem); + backlight_update_status(bd); #ifdef CONFIG_PMAC_BACKLIGHT mutex_lock(&pmac_backlight_mutex); diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 7a85be4d2b0a..347081daf7a4 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c @@ -37,8 +37,7 @@ static int fb_notifier_callback(struct notifier_block *self, if (!bd->props->check_fb || bd->props->check_fb(evdata->info)) { bd->props->fb_blank = *(int *)evdata->data; - if (bd->props && bd->props->update_status) - bd->props->update_status(bd); + backlight_update_status(bd); } up(&bd->sem); return 0; @@ -97,8 +96,7 @@ static ssize_t backlight_store_power(struct class_device *cdev, const char *buf, if (bd->props) { pr_debug("backlight: set power to %d\n", power); bd->props->power = power; - if (bd->props->update_status) - bd->props->update_status(bd); + backlight_update_status(bd); rc = count; } up(&bd->sem); @@ -140,8 +138,7 @@ static ssize_t backlight_store_brightness(struct class_device *cdev, const char pr_debug("backlight: set brightness to %d\n", brightness); bd->props->brightness = brightness; - if (bd->props->update_status) - bd->props->update_status(bd); + backlight_update_status(bd); rc = count; } } @@ -230,6 +227,7 @@ struct backlight_device *backlight_device_register(const char *name, if (!new_bd) return ERR_PTR(-ENOMEM); + mutex_init(&new_bd->update_lock); init_MUTEX(&new_bd->sem); new_bd->props = bp; memset(&new_bd->class_dev, 0, sizeof(new_bd->class_dev)); diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c index 959024812abc..1e1e61a4b5da 100644 --- a/drivers/video/backlight/lcd.c +++ b/drivers/video/backlight/lcd.c @@ -198,6 +198,7 @@ struct lcd_device *lcd_device_register(const char *name, void *devdata, return ERR_PTR(-ENOMEM); init_MUTEX(&new_ld->sem); + mutex_init(&new_ld->update_lock); new_ld->props = lp; memset(&new_ld->class_dev, 0, sizeof(new_ld->class_dev)); new_ld->class_dev.class = &lcd_class; diff --git a/drivers/video/chipsfb.c b/drivers/video/chipsfb.c index 73cb426bf2d7..9a656bc6295c 100644 --- a/drivers/video/chipsfb.c +++ b/drivers/video/chipsfb.c @@ -153,13 +153,11 @@ static int chipsfb_blank(int blank, struct fb_info *info) * useful at blank = 1 too (saves battery, extends backlight * life) */ - down(&pmac_backlight->sem); if (blank) pmac_backlight->props->power = FB_BLANK_POWERDOWN; else pmac_backlight->props->power = FB_BLANK_UNBLANK; - pmac_backlight->props->update_status(pmac_backlight); - up(&pmac_backlight->sem); + backlight_update_status(pmac_backlight); } mutex_unlock(&pmac_backlight_mutex); @@ -415,10 +413,8 @@ chipsfb_pci_init(struct pci_dev *dp, const struct pci_device_id *ent) /* turn on the backlight */ mutex_lock(&pmac_backlight_mutex); if (pmac_backlight) { - down(&pmac_backlight->sem); pmac_backlight->props->power = FB_BLANK_UNBLANK; - pmac_backlight->props->update_status(pmac_backlight); - up(&pmac_backlight->sem); + backlight_update_status(pmac_backlight); } mutex_unlock(&pmac_backlight_mutex); #endif /* CONFIG_PMAC_BACKLIGHT */ diff --git a/drivers/video/nvidia/nv_backlight.c b/drivers/video/nvidia/nv_backlight.c index 4254c090dc4b..f5e42d0bd0da 100644 --- a/drivers/video/nvidia/nv_backlight.c +++ b/drivers/video/nvidia/nv_backlight.c @@ -114,10 +114,8 @@ void nvidia_bl_set_power(struct fb_info *info, int power) mutex_lock(&info->bl_mutex); if (info->bl_dev) { - down(&info->bl_dev->sem); info->bl_dev->props->power = power; __nvidia_bl_update_status(info->bl_dev); - up(&info->bl_dev->sem); } mutex_unlock(&info->bl_mutex); @@ -154,11 +152,9 @@ void nvidia_bl_init(struct nvidia_par *par) 0x534 * FB_BACKLIGHT_MAX / MAX_LEVEL); mutex_unlock(&info->bl_mutex); - down(&bd->sem); bd->props->brightness = nvidia_bl_data.max_brightness; bd->props->power = FB_BLANK_UNBLANK; - bd->props->update_status(bd); - up(&bd->sem); + backlight_update_status(bd); #ifdef CONFIG_PMAC_BACKLIGHT mutex_lock(&pmac_backlight_mutex); diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c index fd825711bb63..b70d18f7fcd9 100644 --- a/drivers/video/riva/fbdev.c +++ b/drivers/video/riva/fbdev.c @@ -357,10 +357,8 @@ static void riva_bl_set_power(struct fb_info *info, int power) mutex_lock(&info->bl_mutex); if (info->bl_dev) { - down(&info->bl_dev->sem); info->bl_dev->props->power = power; __riva_bl_update_status(info->bl_dev); - up(&info->bl_dev->sem); } mutex_unlock(&info->bl_mutex); @@ -397,11 +395,9 @@ static void riva_bl_init(struct riva_par *par) FB_BACKLIGHT_MAX); mutex_unlock(&info->bl_mutex); - down(&bd->sem); bd->props->brightness = riva_bl_data.max_brightness; bd->props->power = FB_BLANK_UNBLANK; - bd->props->update_status(bd); - up(&bd->sem); + backlight_update_status(bd); #ifdef CONFIG_PMAC_BACKLIGHT mutex_lock(&pmac_backlight_mutex); |