[PATCH] backlight last round of fixes

Fix some more problems (inverted use of semaphores in some places). He
also moved my checks into within the protected section which is better.

Signed-off-by: Michael Hanselmann <linux-kernel@hansmi.ch>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Benjamin Herrenschmidt and committed by Linus Torvalds a9303638 4cfb04a9

+44 -39
+2 -2
drivers/macintosh/via-pmu-backlight.c
··· 167 pmu_backlight_data.max_brightness / 15); 168 } 169 170 - up(&bd->sem); 171 bd->props->brightness = level; 172 bd->props->power = FB_BLANK_UNBLANK; 173 bd->props->update_status(bd); 174 - down(&bd->sem); 175 176 mutex_lock(&pmac_backlight_mutex); 177 if (!pmac_backlight)
··· 167 pmu_backlight_data.max_brightness / 15); 168 } 169 170 + down(&bd->sem); 171 bd->props->brightness = level; 172 bd->props->power = FB_BLANK_UNBLANK; 173 bd->props->update_status(bd); 174 + up(&bd->sem); 175 176 mutex_lock(&pmac_backlight_mutex); 177 if (!pmac_backlight)
+10 -9
drivers/video/aty/aty128fb.c
··· 1800 1801 static void aty128_bl_set_power(struct fb_info *info, int power) 1802 { 1803 - if (info->bl_dev == NULL) 1804 - return; 1805 - 1806 mutex_lock(&info->bl_mutex); 1807 - up(&info->bl_dev->sem); 1808 - info->bl_dev->props->power = power; 1809 - __aty128_bl_update_status(info->bl_dev); 1810 - down(&info->bl_dev->sem); 1811 mutex_unlock(&info->bl_mutex); 1812 } 1813 ··· 1843 219 * FB_BACKLIGHT_MAX / MAX_LEVEL); 1844 mutex_unlock(&info->bl_mutex); 1845 1846 - up(&bd->sem); 1847 bd->props->brightness = aty128_bl_data.max_brightness; 1848 bd->props->power = FB_BLANK_UNBLANK; 1849 bd->props->update_status(bd); 1850 - down(&bd->sem); 1851 1852 #ifdef CONFIG_PMAC_BACKLIGHT 1853 mutex_lock(&pmac_backlight_mutex);
··· 1800 1801 static void aty128_bl_set_power(struct fb_info *info, int power) 1802 { 1803 mutex_lock(&info->bl_mutex); 1804 + 1805 + if (info->bl_dev) { 1806 + down(&info->bl_dev->sem); 1807 + info->bl_dev->props->power = power; 1808 + __aty128_bl_update_status(info->bl_dev); 1809 + up(&info->bl_dev->sem); 1810 + } 1811 + 1812 mutex_unlock(&info->bl_mutex); 1813 } 1814 ··· 1842 219 * FB_BACKLIGHT_MAX / MAX_LEVEL); 1843 mutex_unlock(&info->bl_mutex); 1844 1845 + down(&bd->sem); 1846 bd->props->brightness = aty128_bl_data.max_brightness; 1847 bd->props->power = FB_BLANK_UNBLANK; 1848 bd->props->update_status(bd); 1849 + up(&bd->sem); 1850 1851 #ifdef CONFIG_PMAC_BACKLIGHT 1852 mutex_lock(&pmac_backlight_mutex);
+10 -9
drivers/video/aty/atyfb_base.c
··· 2199 2200 static void aty_bl_set_power(struct fb_info *info, int power) 2201 { 2202 - if (info->bl_dev == NULL) 2203 - return; 2204 - 2205 mutex_lock(&info->bl_mutex); 2206 - up(&info->bl_dev->sem); 2207 - info->bl_dev->props->power = power; 2208 - __aty_bl_update_status(info->bl_dev); 2209 - down(&info->bl_dev->sem); 2210 mutex_unlock(&info->bl_mutex); 2211 } 2212 ··· 2238 0xFF * FB_BACKLIGHT_MAX / MAX_LEVEL); 2239 mutex_unlock(&info->bl_mutex); 2240 2241 - up(&bd->sem); 2242 bd->props->brightness = aty_bl_data.max_brightness; 2243 bd->props->power = FB_BLANK_UNBLANK; 2244 bd->props->update_status(bd); 2245 - down(&bd->sem); 2246 2247 #ifdef CONFIG_PMAC_BACKLIGHT 2248 mutex_lock(&pmac_backlight_mutex);
··· 2199 2200 static void aty_bl_set_power(struct fb_info *info, int power) 2201 { 2202 mutex_lock(&info->bl_mutex); 2203 + 2204 + if (info->bl_dev) { 2205 + down(&info->bl_dev->sem); 2206 + info->bl_dev->props->power = power; 2207 + __aty_bl_update_status(info->bl_dev); 2208 + up(&info->bl_dev->sem); 2209 + } 2210 + 2211 mutex_unlock(&info->bl_mutex); 2212 } 2213 ··· 2237 0xFF * FB_BACKLIGHT_MAX / MAX_LEVEL); 2238 mutex_unlock(&info->bl_mutex); 2239 2240 + down(&bd->sem); 2241 bd->props->brightness = aty_bl_data.max_brightness; 2242 bd->props->power = FB_BLANK_UNBLANK; 2243 bd->props->update_status(bd); 2244 + up(&bd->sem); 2245 2246 #ifdef CONFIG_PMAC_BACKLIGHT 2247 mutex_lock(&pmac_backlight_mutex);
+2 -2
drivers/video/aty/radeon_backlight.c
··· 195 217 * FB_BACKLIGHT_MAX / MAX_RADEON_LEVEL); 196 mutex_unlock(&rinfo->info->bl_mutex); 197 198 - up(&bd->sem); 199 bd->props->brightness = radeon_bl_data.max_brightness; 200 bd->props->power = FB_BLANK_UNBLANK; 201 bd->props->update_status(bd); 202 - down(&bd->sem); 203 204 #ifdef CONFIG_PMAC_BACKLIGHT 205 mutex_lock(&pmac_backlight_mutex);
··· 195 217 * FB_BACKLIGHT_MAX / MAX_RADEON_LEVEL); 196 mutex_unlock(&rinfo->info->bl_mutex); 197 198 + down(&bd->sem); 199 bd->props->brightness = radeon_bl_data.max_brightness; 200 bd->props->power = FB_BLANK_UNBLANK; 201 bd->props->update_status(bd); 202 + up(&bd->sem); 203 204 #ifdef CONFIG_PMAC_BACKLIGHT 205 mutex_lock(&pmac_backlight_mutex);
+10 -8
drivers/video/nvidia/nv_backlight.c
··· 112 113 void nvidia_bl_set_power(struct fb_info *info, int power) 114 { 115 - if (info->bl_dev == NULL) 116 - return; 117 mutex_lock(&info->bl_mutex); 118 - up(&info->bl_dev->sem); 119 - info->bl_dev->props->power = power; 120 - __nvidia_bl_update_status(info->bl_dev); 121 - down(&info->bl_dev->sem); 122 mutex_unlock(&info->bl_mutex); 123 } 124 ··· 155 0x534 * FB_BACKLIGHT_MAX / MAX_LEVEL); 156 mutex_unlock(&info->bl_mutex); 157 158 - up(&bd->sem); 159 bd->props->brightness = nvidia_bl_data.max_brightness; 160 bd->props->power = FB_BLANK_UNBLANK; 161 bd->props->update_status(bd); 162 - down(&bd->sem); 163 164 #ifdef CONFIG_PMAC_BACKLIGHT 165 mutex_lock(&pmac_backlight_mutex);
··· 112 113 void nvidia_bl_set_power(struct fb_info *info, int power) 114 { 115 mutex_lock(&info->bl_mutex); 116 + 117 + if (info->bl_dev) { 118 + down(&info->bl_dev->sem); 119 + info->bl_dev->props->power = power; 120 + __nvidia_bl_update_status(info->bl_dev); 121 + up(&info->bl_dev->sem); 122 + } 123 + 124 mutex_unlock(&info->bl_mutex); 125 } 126 ··· 153 0x534 * FB_BACKLIGHT_MAX / MAX_LEVEL); 154 mutex_unlock(&info->bl_mutex); 155 156 + down(&bd->sem); 157 bd->props->brightness = nvidia_bl_data.max_brightness; 158 bd->props->power = FB_BLANK_UNBLANK; 159 bd->props->update_status(bd); 160 + up(&bd->sem); 161 162 #ifdef CONFIG_PMAC_BACKLIGHT 163 mutex_lock(&pmac_backlight_mutex);
+10 -9
drivers/video/riva/fbdev.c
··· 354 355 static void riva_bl_set_power(struct fb_info *info, int power) 356 { 357 - if (info->bl_dev == NULL) 358 - return; 359 - 360 mutex_lock(&info->bl_mutex); 361 - up(&info->bl_dev->sem); 362 - info->bl_dev->props->power = power; 363 - __riva_bl_update_status(info->bl_dev); 364 - down(&info->bl_dev->sem); 365 mutex_unlock(&info->bl_mutex); 366 } 367 ··· 397 0x534 * FB_BACKLIGHT_MAX / MAX_LEVEL); 398 mutex_unlock(&info->bl_mutex); 399 400 - up(&bd->sem); 401 bd->props->brightness = riva_bl_data.max_brightness; 402 bd->props->power = FB_BLANK_UNBLANK; 403 bd->props->update_status(bd); 404 - down(&bd->sem); 405 406 #ifdef CONFIG_PMAC_BACKLIGHT 407 mutex_lock(&pmac_backlight_mutex);
··· 354 355 static void riva_bl_set_power(struct fb_info *info, int power) 356 { 357 mutex_lock(&info->bl_mutex); 358 + 359 + if (info->bl_dev) { 360 + down(&info->bl_dev->sem); 361 + info->bl_dev->props->power = power; 362 + __riva_bl_update_status(info->bl_dev); 363 + up(&info->bl_dev->sem); 364 + } 365 + 366 mutex_unlock(&info->bl_mutex); 367 } 368 ··· 396 0x534 * FB_BACKLIGHT_MAX / MAX_LEVEL); 397 mutex_unlock(&info->bl_mutex); 398 399 + down(&bd->sem); 400 bd->props->brightness = riva_bl_data.max_brightness; 401 bd->props->power = FB_BLANK_UNBLANK; 402 bd->props->update_status(bd); 403 + up(&bd->sem); 404 405 #ifdef CONFIG_PMAC_BACKLIGHT 406 mutex_lock(&pmac_backlight_mutex);