aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/aty/atyfb_base.c
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@rpsys.net>2007-02-10 09:10:33 -0500
committerRichard Purdie <rpurdie@rpsys.net>2007-02-20 03:38:46 -0500
commit37ce69a57ff217a4ca0871e9ee5aa58c052b7d86 (patch)
tree21cdbb8c988eed585437bb502ca15c2998ea7fbc /drivers/video/aty/atyfb_base.c
parentb5c6916b3118d4301dc2f8cf8d33f13e5324a3a5 (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/aty/atyfb_base.c')
-rw-r--r--drivers/video/aty/atyfb_base.c49
1 files changed, 11 insertions, 38 deletions
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
index 3b6529392359..66462286e704 100644
--- a/drivers/video/aty/atyfb_base.c
+++ b/drivers/video/aty/atyfb_base.c
@@ -2116,13 +2116,13 @@ static int atyfb_pci_resume(struct pci_dev *pdev)
2116 2116
2117static struct backlight_properties aty_bl_data; 2117static struct backlight_properties aty_bl_data;
2118 2118
2119/* Call with fb_info->bl_mutex held */
2120static int aty_bl_get_level_brightness(struct atyfb_par *par, int level) 2119static int aty_bl_get_level_brightness(struct atyfb_par *par, int level)
2121{ 2120{
2122 struct fb_info *info = pci_get_drvdata(par->pdev); 2121 struct fb_info *info = pci_get_drvdata(par->pdev);
2123 int atylevel; 2122 int atylevel;
2124 2123
2125 /* Get and convert the value */ 2124 /* Get and convert the value */
2125 /* No locking of bl_curve since we read a single value */
2126 atylevel = info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL; 2126 atylevel = info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL;
2127 2127
2128 if (atylevel < 0) 2128 if (atylevel < 0)
@@ -2133,8 +2133,7 @@ static int aty_bl_get_level_brightness(struct atyfb_par *par, int level)
2133 return atylevel; 2133 return atylevel;
2134} 2134}
2135 2135
2136/* Call with fb_info->bl_mutex held */ 2136static int aty_bl_update_status(struct backlight_device *bd)
2137static int __aty_bl_update_status(struct backlight_device *bd)
2138{ 2137{
2139 struct atyfb_par *par = class_get_devdata(&bd->class_dev); 2138 struct atyfb_par *par = class_get_devdata(&bd->class_dev);
2140 unsigned int reg = aty_ld_lcd(LCD_MISC_CNTL, par); 2139 unsigned int reg = aty_ld_lcd(LCD_MISC_CNTL, par);
@@ -2159,19 +2158,6 @@ static int __aty_bl_update_status(struct backlight_device *bd)
2159 return 0; 2158 return 0;
2160} 2159}
2161 2160
2162static int aty_bl_update_status(struct backlight_device *bd)
2163{
2164 struct atyfb_par *par = class_get_devdata(&bd->class_dev);
2165 struct fb_info *info = pci_get_drvdata(par->pdev);
2166 int ret;
2167
2168 mutex_lock(&info->bl_mutex);
2169 ret = __aty_bl_update_status(bd);
2170 mutex_unlock(&info->bl_mutex);
2171
2172 return ret;
2173}
2174
2175static int aty_bl_get_brightness(struct backlight_device *bd) 2161static int aty_bl_get_brightness(struct backlight_device *bd)
2176{ 2162{
2177 return bd->props->brightness; 2163 return bd->props->brightness;
@@ -2203,12 +2189,10 @@ static void aty_bl_init(struct atyfb_par *par)
2203 goto error; 2189 goto error;
2204 } 2190 }
2205 2191
2206 mutex_lock(&info->bl_mutex);
2207 info->bl_dev = bd; 2192 info->bl_dev = bd;
2208 fb_bl_default_curve(info, 0, 2193 fb_bl_default_curve(info, 0,
2209 0x3F * FB_BACKLIGHT_MAX / MAX_LEVEL, 2194 0x3F * FB_BACKLIGHT_MAX / MAX_LEVEL,
2210 0xFF * FB_BACKLIGHT_MAX / MAX_LEVEL); 2195 0xFF * FB_BACKLIGHT_MAX / MAX_LEVEL);
2211 mutex_unlock(&info->bl_mutex);
2212 2196
2213 bd->props->brightness = aty_bl_data.max_brightness; 2197 bd->props->brightness = aty_bl_data.max_brightness;
2214 bd->props->power = FB_BLANK_UNBLANK; 2198 bd->props->power = FB_BLANK_UNBLANK;
@@ -2229,30 +2213,19 @@ error:
2229 return; 2213 return;
2230} 2214}
2231 2215
2232static void aty_bl_exit(struct atyfb_par *par) 2216static void aty_bl_exit(struct backlight_device *bd)
2233{ 2217{
2234 struct fb_info *info = pci_get_drvdata(par->pdev); 2218 if (bd) {
2235
2236#ifdef CONFIG_PMAC_BACKLIGHT 2219#ifdef CONFIG_PMAC_BACKLIGHT
2237 mutex_lock(&pmac_backlight_mutex); 2220 mutex_lock(&pmac_backlight_mutex);
2238#endif 2221 if (pmac_backlight == bd)
2239
2240 mutex_lock(&info->bl_mutex);
2241 if (info->bl_dev) {
2242#ifdef CONFIG_PMAC_BACKLIGHT
2243 if (pmac_backlight == info->bl_dev)
2244 pmac_backlight = NULL; 2222 pmac_backlight = NULL;
2223 mutex_unlock(&pmac_backlight_mutex);
2245#endif 2224#endif
2246 2225 backlight_device_unregister(bd);
2247 backlight_device_unregister(info->bl_dev);
2248 2226
2249 printk("aty: Backlight unloaded\n"); 2227 printk("aty: Backlight unloaded\n");
2250 } 2228 }
2251 mutex_unlock(&info->bl_mutex);
2252
2253#ifdef CONFIG_PMAC_BACKLIGHT
2254 mutex_unlock(&pmac_backlight_mutex);
2255#endif
2256} 2229}
2257 2230
2258#endif /* CONFIG_FB_ATY_BACKLIGHT */ 2231#endif /* CONFIG_FB_ATY_BACKLIGHT */
@@ -3705,13 +3678,13 @@ static void __devexit atyfb_remove(struct fb_info *info)
3705 aty_set_crtc(par, &saved_crtc); 3678 aty_set_crtc(par, &saved_crtc);
3706 par->pll_ops->set_pll(info, &saved_pll); 3679 par->pll_ops->set_pll(info, &saved_pll);
3707 3680
3681 unregister_framebuffer(info);
3682
3708#ifdef CONFIG_FB_ATY_BACKLIGHT 3683#ifdef CONFIG_FB_ATY_BACKLIGHT
3709 if (M64_HAS(MOBIL_BUS)) 3684 if (M64_HAS(MOBIL_BUS))
3710 aty_bl_exit(par); 3685 aty_bl_exit(info->bl_dev);
3711#endif 3686#endif
3712 3687
3713 unregister_framebuffer(info);
3714
3715#ifdef CONFIG_MTRR 3688#ifdef CONFIG_MTRR
3716 if (par->mtrr_reg >= 0) { 3689 if (par->mtrr_reg >= 0) {
3717 mtrr_del(par->mtrr_reg, 0, 0); 3690 mtrr_del(par->mtrr_reg, 0, 0);