summaryrefslogtreecommitdiffstats
path: root/drivers/video/nvidia
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@rpsys.net>2007-02-10 14:10:33 +0000
committerRichard Purdie <rpurdie@rpsys.net>2007-02-20 08:38:46 +0000
commit37ce69a57ff217a4ca0871e9ee5aa58c052b7d86 (patch)
tree21cdbb8c988eed585437bb502ca15c2998ea7fbc /drivers/video/nvidia
parentb5c6916b3118d4301dc2f8cf8d33f13e5324a3a5 (diff)
downloadblackbird-op-linux-37ce69a57ff217a4ca0871e9ee5aa58c052b7d86.tar.gz
blackbird-op-linux-37ce69a57ff217a4ca0871e9ee5aa58c052b7d86.zip
backlight: Rework backlight/fb interaction simplifying, lots
fb_info->bl_mutex is badly thought out and the backlight class doesn't need it if the framebuffer/backlight register/unregister order is consistent, particularly after the backlight locking fixes. Fix the drivers to use the order: backlight_device_register() register_framebuffer() unregister_framebuffer() backlight_device_unregister() and turn bl_mutex into a lock for the bl_curve data only. Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Diffstat (limited to 'drivers/video/nvidia')
-rw-r--r--drivers/video/nvidia/nv_backlight.c40
-rw-r--r--drivers/video/nvidia/nvidia.c3
2 files changed, 10 insertions, 33 deletions
diff --git a/drivers/video/nvidia/nv_backlight.c b/drivers/video/nvidia/nv_backlight.c
index 695b6bf54d92..2bebfeeb4f1d 100644
--- a/drivers/video/nvidia/nv_backlight.c
+++ b/drivers/video/nvidia/nv_backlight.c
@@ -30,7 +30,6 @@
static struct backlight_properties nvidia_bl_data;
-/* Call with fb_info->bl_mutex held */
static int nvidia_bl_get_level_brightness(struct nvidia_par *par,
int level)
{
@@ -38,6 +37,7 @@ static int nvidia_bl_get_level_brightness(struct nvidia_par *par,
int nlevel;
/* Get and convert the value */
+ /* No locking of bl_curve since we read a single value */
nlevel = MIN_LEVEL + info->bl_curve[level] * LEVEL_STEP;
if (nlevel < 0)
@@ -50,8 +50,7 @@ static int nvidia_bl_get_level_brightness(struct nvidia_par *par,
return nlevel;
}
-/* Call with fb_info->bl_mutex held */
-static int __nvidia_bl_update_status(struct backlight_device *bd)
+static int nvidia_bl_update_status(struct backlight_device *bd)
{
struct nvidia_par *par = class_get_devdata(&bd->class_dev);
u32 tmp_pcrt, tmp_pmc, fpcontrol;
@@ -85,19 +84,6 @@ static int __nvidia_bl_update_status(struct backlight_device *bd)
return 0;
}
-static int nvidia_bl_update_status(struct backlight_device *bd)
-{
- struct nvidia_par *par = class_get_devdata(&bd->class_dev);
- struct fb_info *info = pci_get_drvdata(par->pci_dev);
- int ret;
-
- mutex_lock(&info->bl_mutex);
- ret = __nvidia_bl_update_status(bd);
- mutex_unlock(&info->bl_mutex);
-
- return ret;
-}
-
static int nvidia_bl_get_brightness(struct backlight_device *bd)
{
return bd->props->brightness;
@@ -133,12 +119,10 @@ void nvidia_bl_init(struct nvidia_par *par)
goto error;
}
- mutex_lock(&info->bl_mutex);
info->bl_dev = bd;
fb_bl_default_curve(info, 0,
0x158 * FB_BACKLIGHT_MAX / MAX_LEVEL,
0x534 * FB_BACKLIGHT_MAX / MAX_LEVEL);
- mutex_unlock(&info->bl_mutex);
bd->props->brightness = nvidia_bl_data.max_brightness;
bd->props->power = FB_BLANK_UNBLANK;
@@ -162,25 +146,17 @@ error:
void nvidia_bl_exit(struct nvidia_par *par)
{
struct fb_info *info = pci_get_drvdata(par->pci_dev);
+ struct backlight_device *bd = info->bl_dev;
+ if (bd) {
#ifdef CONFIG_PMAC_BACKLIGHT
- mutex_lock(&pmac_backlight_mutex);
-#endif
-
- mutex_lock(&info->bl_mutex);
- if (info->bl_dev) {
-#ifdef CONFIG_PMAC_BACKLIGHT
- if (pmac_backlight == info->bl_dev)
+ mutex_lock(&pmac_backlight_mutex);
+ if (pmac_backlight == bd)
pmac_backlight = NULL;
+ mutex_unlock(&pmac_backlight_mutex);
#endif
-
- backlight_device_unregister(info->bl_dev);
+ backlight_device_unregister(bd);
printk("nvidia: Backlight unloaded\n");
}
- mutex_unlock(&info->bl_mutex);
-
-#ifdef CONFIG_PMAC_BACKLIGHT
- mutex_unlock(&pmac_backlight_mutex);
-#endif
}
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
index 64f59119c422..c18e9557ca30 100644
--- a/drivers/video/nvidia/nvidia.c
+++ b/drivers/video/nvidia/nvidia.c
@@ -1350,9 +1350,10 @@ static void __devexit nvidiafb_remove(struct pci_dev *pd)
NVTRACE_ENTER();
+ unregister_framebuffer(info);
+
nvidia_bl_exit(par);
- unregister_framebuffer(info);
#ifdef CONFIG_MTRR
if (par->mtrr.vram_valid)
mtrr_del(par->mtrr.vram, info->fix.smem_start,
OpenPOWER on IntegriCloud