diff options
author | Richard Purdie <rpurdie@rpsys.net> | 2007-02-10 09:10:33 -0500 |
---|---|---|
committer | Richard Purdie <rpurdie@rpsys.net> | 2007-02-20 03:38:46 -0500 |
commit | 37ce69a57ff217a4ca0871e9ee5aa58c052b7d86 (patch) | |
tree | 21cdbb8c988eed585437bb502ca15c2998ea7fbc /drivers/video/riva | |
parent | b5c6916b3118d4301dc2f8cf8d33f13e5324a3a5 (diff) |
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/riva')
-rw-r--r-- | drivers/video/riva/fbdev.c | 50 |
1 files changed, 13 insertions, 37 deletions
diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c index 9e7d3fcde207..ab00350907dd 100644 --- a/drivers/video/riva/fbdev.c +++ b/drivers/video/riva/fbdev.c | |||
@@ -282,7 +282,6 @@ static const struct riva_regs reg_template = { | |||
282 | 282 | ||
283 | static struct backlight_properties riva_bl_data; | 283 | static struct backlight_properties riva_bl_data; |
284 | 284 | ||
285 | /* Call with fb_info->bl_mutex held */ | ||
286 | static int riva_bl_get_level_brightness(struct riva_par *par, | 285 | static int riva_bl_get_level_brightness(struct riva_par *par, |
287 | int level) | 286 | int level) |
288 | { | 287 | { |
@@ -290,6 +289,7 @@ static int riva_bl_get_level_brightness(struct riva_par *par, | |||
290 | int nlevel; | 289 | int nlevel; |
291 | 290 | ||
292 | /* Get and convert the value */ | 291 | /* Get and convert the value */ |
292 | /* No locking on bl_curve since accessing a single value */ | ||
293 | nlevel = MIN_LEVEL + info->bl_curve[level] * LEVEL_STEP; | 293 | nlevel = MIN_LEVEL + info->bl_curve[level] * LEVEL_STEP; |
294 | 294 | ||
295 | if (nlevel < 0) | 295 | if (nlevel < 0) |
@@ -302,8 +302,7 @@ static int riva_bl_get_level_brightness(struct riva_par *par, | |||
302 | return nlevel; | 302 | return nlevel; |
303 | } | 303 | } |
304 | 304 | ||
305 | /* Call with fb_info->bl_mutex held */ | 305 | static int riva_bl_update_status(struct backlight_device *bd) |
306 | static int __riva_bl_update_status(struct backlight_device *bd) | ||
307 | { | 306 | { |
308 | struct riva_par *par = class_get_devdata(&bd->class_dev); | 307 | struct riva_par *par = class_get_devdata(&bd->class_dev); |
309 | U032 tmp_pcrt, tmp_pmc; | 308 | U032 tmp_pcrt, tmp_pmc; |
@@ -328,19 +327,6 @@ static int __riva_bl_update_status(struct backlight_device *bd) | |||
328 | return 0; | 327 | return 0; |
329 | } | 328 | } |
330 | 329 | ||
331 | static int riva_bl_update_status(struct backlight_device *bd) | ||
332 | { | ||
333 | struct riva_par *par = class_get_devdata(&bd->class_dev); | ||
334 | struct fb_info *info = pci_get_drvdata(par->pdev); | ||
335 | int ret; | ||
336 | |||
337 | mutex_lock(&info->bl_mutex); | ||
338 | ret = __riva_bl_update_status(bd); | ||
339 | mutex_unlock(&info->bl_mutex); | ||
340 | |||
341 | return ret; | ||
342 | } | ||
343 | |||
344 | static int riva_bl_get_brightness(struct backlight_device *bd) | 330 | static int riva_bl_get_brightness(struct backlight_device *bd) |
345 | { | 331 | { |
346 | return bd->props->brightness; | 332 | return bd->props->brightness; |
@@ -376,12 +362,10 @@ static void riva_bl_init(struct riva_par *par) | |||
376 | goto error; | 362 | goto error; |
377 | } | 363 | } |
378 | 364 | ||
379 | mutex_lock(&info->bl_mutex); | ||
380 | info->bl_dev = bd; | 365 | info->bl_dev = bd; |
381 | fb_bl_default_curve(info, 0, | 366 | fb_bl_default_curve(info, 0, |
382 | MIN_LEVEL * FB_BACKLIGHT_MAX / MAX_LEVEL, | 367 | MIN_LEVEL * FB_BACKLIGHT_MAX / MAX_LEVEL, |
383 | FB_BACKLIGHT_MAX); | 368 | FB_BACKLIGHT_MAX); |
384 | mutex_unlock(&info->bl_mutex); | ||
385 | 369 | ||
386 | bd->props->brightness = riva_bl_data.max_brightness; | 370 | bd->props->brightness = riva_bl_data.max_brightness; |
387 | bd->props->power = FB_BLANK_UNBLANK; | 371 | bd->props->power = FB_BLANK_UNBLANK; |
@@ -402,34 +386,25 @@ error: | |||
402 | return; | 386 | return; |
403 | } | 387 | } |
404 | 388 | ||
405 | static void riva_bl_exit(struct riva_par *par) | 389 | static void riva_bl_exit(struct fb_info *info) |
406 | { | 390 | { |
407 | struct fb_info *info = pci_get_drvdata(par->pdev); | 391 | struct backlight_device *bd = info->bl_dev; |
408 | 392 | ||
393 | if (bd) { | ||
409 | #ifdef CONFIG_PMAC_BACKLIGHT | 394 | #ifdef CONFIG_PMAC_BACKLIGHT |
410 | mutex_lock(&pmac_backlight_mutex); | 395 | mutex_lock(&pmac_backlight_mutex); |
411 | #endif | 396 | if (pmac_backlight == bd) |
412 | |||
413 | mutex_lock(&info->bl_mutex); | ||
414 | if (info->bl_dev) { | ||
415 | #ifdef CONFIG_PMAC_BACKLIGHT | ||
416 | if (pmac_backlight == info->bl_dev) | ||
417 | pmac_backlight = NULL; | 397 | pmac_backlight = NULL; |
398 | mutex_unlock(&pmac_backlight_mutex); | ||
418 | #endif | 399 | #endif |
419 | 400 | backlight_device_unregister(bd); | |
420 | backlight_device_unregister(info->bl_dev); | ||
421 | 401 | ||
422 | printk("riva: Backlight unloaded\n"); | 402 | printk("riva: Backlight unloaded\n"); |
423 | } | 403 | } |
424 | mutex_unlock(&info->bl_mutex); | ||
425 | |||
426 | #ifdef CONFIG_PMAC_BACKLIGHT | ||
427 | mutex_unlock(&pmac_backlight_mutex); | ||
428 | #endif | ||
429 | } | 404 | } |
430 | #else | 405 | #else |
431 | static inline void riva_bl_init(struct riva_par *par) {} | 406 | static inline void riva_bl_init(struct riva_par *par) {} |
432 | static inline void riva_bl_exit(struct riva_par *par) {} | 407 | static inline void riva_bl_exit(struct fb_info *info) {} |
433 | #endif /* CONFIG_FB_RIVA_BACKLIGHT */ | 408 | #endif /* CONFIG_FB_RIVA_BACKLIGHT */ |
434 | 409 | ||
435 | /* ------------------------------------------------------------------------- * | 410 | /* ------------------------------------------------------------------------- * |
@@ -2146,14 +2121,15 @@ static void __exit rivafb_remove(struct pci_dev *pd) | |||
2146 | 2121 | ||
2147 | NVTRACE_ENTER(); | 2122 | NVTRACE_ENTER(); |
2148 | 2123 | ||
2149 | riva_bl_exit(par); | ||
2150 | |||
2151 | #ifdef CONFIG_FB_RIVA_I2C | 2124 | #ifdef CONFIG_FB_RIVA_I2C |
2152 | riva_delete_i2c_busses(par); | 2125 | riva_delete_i2c_busses(par); |
2153 | kfree(par->EDID); | 2126 | kfree(par->EDID); |
2154 | #endif | 2127 | #endif |
2155 | 2128 | ||
2156 | unregister_framebuffer(info); | 2129 | unregister_framebuffer(info); |
2130 | |||
2131 | riva_bl_exit(info); | ||
2132 | |||
2157 | #ifdef CONFIG_MTRR | 2133 | #ifdef CONFIG_MTRR |
2158 | if (par->mtrr.vram_valid) | 2134 | if (par->mtrr.vram_valid) |
2159 | mtrr_del(par->mtrr.vram, info->fix.smem_start, | 2135 | mtrr_del(par->mtrr.vram, info->fix.smem_start, |