aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@rpsys.net>2007-02-10 10:04:08 -0500
committerRichard Purdie <rpurdie@rpsys.net>2007-02-20 04:26:40 -0500
commit321709c5994f952b78d567fd7083dbebbdc381b7 (patch)
treedf237c216e8bab6ce5c14d5797a796d4bf889a92
parente0e34ef7f02915cfe50e501e9f32c24217177a96 (diff)
backlight: Clean up pmac_backlight handling
Move the setting/unsetting of pmac_backlight into the backlight core instead of doing it in each driver. Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
-rw-r--r--drivers/macintosh/via-pmu-backlight.c5
-rw-r--r--drivers/misc/sony-laptop.c15
-rw-r--r--drivers/video/aty/aty128fb.c20
-rw-r--r--drivers/video/aty/atyfb_base.c20
-rw-r--r--drivers/video/aty/radeon_backlight.c13
-rw-r--r--drivers/video/backlight/backlight.c17
-rw-r--r--drivers/video/nvidia/nv_backlight.c25
-rw-r--r--drivers/video/riva/fbdev.c20
8 files changed, 34 insertions, 101 deletions
diff --git a/drivers/macintosh/via-pmu-backlight.c b/drivers/macintosh/via-pmu-backlight.c
index 7ba2042b2dd0..9f9d03127978 100644
--- a/drivers/macintosh/via-pmu-backlight.c
+++ b/drivers/macintosh/via-pmu-backlight.c
@@ -170,11 +170,6 @@ void __init pmu_backlight_init()
170 bd->props->power = FB_BLANK_UNBLANK; 170 bd->props->power = FB_BLANK_UNBLANK;
171 backlight_update_status(bd); 171 backlight_update_status(bd);
172 172
173 mutex_lock(&pmac_backlight_mutex);
174 if (!pmac_backlight)
175 pmac_backlight = bd;
176 mutex_unlock(&pmac_backlight_mutex);
177
178 printk("pmubl: Backlight initialized (%s)\n", name); 173 printk("pmubl: Backlight initialized (%s)\n", name);
179 174
180 return; 175 return;
diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c
index 03d02bd9f122..2ebe240dd537 100644
--- a/drivers/misc/sony-laptop.c
+++ b/drivers/misc/sony-laptop.c
@@ -384,7 +384,7 @@ static void sony_snc_pf_remove(void)
384static int sony_backlight_update_status(struct backlight_device *bd) 384static int sony_backlight_update_status(struct backlight_device *bd)
385{ 385{
386 return acpi_callsetfunc(sony_acpi_handle, "SBRT", 386 return acpi_callsetfunc(sony_acpi_handle, "SBRT",
387 bd->props->brightness + 1, NULL); 387 bd->props.brightness + 1, NULL);
388} 388}
389 389
390static int sony_backlight_get_brightness(struct backlight_device *bd) 390static int sony_backlight_get_brightness(struct backlight_device *bd)
@@ -398,10 +398,9 @@ static int sony_backlight_get_brightness(struct backlight_device *bd)
398} 398}
399 399
400static struct backlight_device *sony_backlight_device; 400static struct backlight_device *sony_backlight_device;
401static struct backlight_properties sony_backlight_properties = { 401static struct backlight_ops sony_backlight_ops = {
402 .update_status = sony_backlight_update_status, 402 .update_status = sony_backlight_update_status,
403 .get_brightness = sony_backlight_get_brightness, 403 .get_brightness = sony_backlight_get_brightness,
404 .max_brightness = SONY_MAX_BRIGHTNESS - 1,
405}; 404};
406 405
407/* 406/*
@@ -483,15 +482,19 @@ static int sony_acpi_add(struct acpi_device *device)
483 if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, "GBRT", &handle))) { 482 if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, "GBRT", &handle))) {
484 sony_backlight_device = backlight_device_register("sony", NULL, 483 sony_backlight_device = backlight_device_register("sony", NULL,
485 NULL, 484 NULL,
486 &sony_backlight_properties); 485 &sony_backlight_ops);
487 486
488 if (IS_ERR(sony_backlight_device)) { 487 if (IS_ERR(sony_backlight_device)) {
489 printk(LOG_PFX "unable to register backlight device\n"); 488 printk(LOG_PFX "unable to register backlight device\n");
490 sony_backlight_device = NULL; 489 sony_backlight_device = NULL;
491 } else 490 } else {
492 sony_backlight_properties.brightness = 491 sony_backlight_device->props.brightness =
493 sony_backlight_get_brightness 492 sony_backlight_get_brightness
494 (sony_backlight_device); 493 (sony_backlight_device);
494 sony_backlight_device->props.max_brightness =
495 SONY_MAX_BRIGHTNESS - 1;
496 }
497
495 } 498 }
496 499
497 if (sony_snc_pf_add()) 500 if (sony_snc_pf_add())
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
index ef3e7861c27a..4de8d6252c3c 100644
--- a/drivers/video/aty/aty128fb.c
+++ b/drivers/video/aty/aty128fb.c
@@ -1829,13 +1829,6 @@ static void aty128_bl_init(struct aty128fb_par *par)
1829 bd->props->power = FB_BLANK_UNBLANK; 1829 bd->props->power = FB_BLANK_UNBLANK;
1830 backlight_update_status(bd); 1830 backlight_update_status(bd);
1831 1831
1832#ifdef CONFIG_PMAC_BACKLIGHT
1833 mutex_lock(&pmac_backlight_mutex);
1834 if (!pmac_backlight)
1835 pmac_backlight = bd;
1836 mutex_unlock(&pmac_backlight_mutex);
1837#endif
1838
1839 printk("aty128: Backlight initialized (%s)\n", name); 1832 printk("aty128: Backlight initialized (%s)\n", name);
1840 1833
1841 return; 1834 return;
@@ -1846,17 +1839,8 @@ error:
1846 1839
1847static void aty128_bl_exit(struct backlight_device *bd) 1840static void aty128_bl_exit(struct backlight_device *bd)
1848{ 1841{
1849 if (bd) { 1842 backlight_device_unregister(bd);
1850#ifdef CONFIG_PMAC_BACKLIGHT 1843 printk("aty128: Backlight unloaded\n");
1851 mutex_lock(&pmac_backlight_mutex);
1852 if (pmac_backlight == bd)
1853 pmac_backlight = NULL;
1854 mutex_unlock(&pmac_backlight_mutex);
1855#endif
1856 backlight_device_unregister(bd);
1857
1858 printk("aty128: Backlight unloaded\n");
1859 }
1860} 1844}
1861#endif /* CONFIG_FB_ATY128_BACKLIGHT */ 1845#endif /* CONFIG_FB_ATY128_BACKLIGHT */
1862 1846
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
index 66462286e704..35ba26567598 100644
--- a/drivers/video/aty/atyfb_base.c
+++ b/drivers/video/aty/atyfb_base.c
@@ -2198,13 +2198,6 @@ static void aty_bl_init(struct atyfb_par *par)
2198 bd->props->power = FB_BLANK_UNBLANK; 2198 bd->props->power = FB_BLANK_UNBLANK;
2199 backlight_update_status(bd); 2199 backlight_update_status(bd);
2200 2200
2201#ifdef CONFIG_PMAC_BACKLIGHT
2202 mutex_lock(&pmac_backlight_mutex);
2203 if (!pmac_backlight)
2204 pmac_backlight = bd;
2205 mutex_unlock(&pmac_backlight_mutex);
2206#endif
2207
2208 printk("aty: Backlight initialized (%s)\n", name); 2201 printk("aty: Backlight initialized (%s)\n", name);
2209 2202
2210 return; 2203 return;
@@ -2215,17 +2208,8 @@ error:
2215 2208
2216static void aty_bl_exit(struct backlight_device *bd) 2209static void aty_bl_exit(struct backlight_device *bd)
2217{ 2210{
2218 if (bd) { 2211 backlight_device_unregister(bd);
2219#ifdef CONFIG_PMAC_BACKLIGHT 2212 printk("aty: Backlight unloaded\n");
2220 mutex_lock(&pmac_backlight_mutex);
2221 if (pmac_backlight == bd)
2222 pmac_backlight = NULL;
2223 mutex_unlock(&pmac_backlight_mutex);
2224#endif
2225 backlight_device_unregister(bd);
2226
2227 printk("aty: Backlight unloaded\n");
2228 }
2229} 2213}
2230 2214
2231#endif /* CONFIG_FB_ATY_BACKLIGHT */ 2215#endif /* CONFIG_FB_ATY_BACKLIGHT */
diff --git a/drivers/video/aty/radeon_backlight.c b/drivers/video/aty/radeon_backlight.c
index f94e4616788d..8c775e6a7e03 100644
--- a/drivers/video/aty/radeon_backlight.c
+++ b/drivers/video/aty/radeon_backlight.c
@@ -192,13 +192,6 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo)
192 bd->props->power = FB_BLANK_UNBLANK; 192 bd->props->power = FB_BLANK_UNBLANK;
193 backlight_update_status(bd); 193 backlight_update_status(bd);
194 194
195#ifdef CONFIG_PMAC_BACKLIGHT
196 mutex_lock(&pmac_backlight_mutex);
197 if (!pmac_backlight)
198 pmac_backlight = bd;
199 mutex_unlock(&pmac_backlight_mutex);
200#endif
201
202 printk("radeonfb: Backlight initialized (%s)\n", name); 195 printk("radeonfb: Backlight initialized (%s)\n", name);
203 196
204 return; 197 return;
@@ -215,12 +208,6 @@ void radeonfb_bl_exit(struct radeonfb_info *rinfo)
215 if (bd) { 208 if (bd) {
216 struct radeon_bl_privdata *pdata; 209 struct radeon_bl_privdata *pdata;
217 210
218#ifdef CONFIG_PMAC_BACKLIGHT
219 mutex_lock(&pmac_backlight_mutex);
220 if (pmac_backlight == bd)
221 pmac_backlight = NULL;
222 mutex_unlock(&pmac_backlight_mutex);
223#endif
224 pdata = class_get_devdata(&bd->class_dev); 211 pdata = class_get_devdata(&bd->class_dev);
225 backlight_device_unregister(bd); 212 backlight_device_unregister(bd);
226 kfree(pdata); 213 kfree(pdata);
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 5490b2ae5134..822a373d3346 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -14,6 +14,9 @@
14#include <linux/err.h> 14#include <linux/err.h>
15#include <linux/fb.h> 15#include <linux/fb.h>
16 16
17#ifdef CONFIG_PMAC_BACKLIGHT
18#include <asm/backlight.h>
19#endif
17 20
18#if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \ 21#if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
19 defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)) 22 defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE))
@@ -262,6 +265,13 @@ struct backlight_device *backlight_device_register(const char *name,
262 } 265 }
263 } 266 }
264 267
268#ifdef CONFIG_PMAC_BACKLIGHT
269 mutex_lock(&pmac_backlight_mutex);
270 if (!pmac_backlight)
271 pmac_backlight = new_bd;
272 mutex_unlock(&pmac_backlight_mutex);
273#endif
274
265 return new_bd; 275 return new_bd;
266} 276}
267EXPORT_SYMBOL(backlight_device_register); 277EXPORT_SYMBOL(backlight_device_register);
@@ -281,6 +291,13 @@ void backlight_device_unregister(struct backlight_device *bd)
281 291
282 pr_debug("backlight_device_unregister: name=%s\n", bd->class_dev.class_id); 292 pr_debug("backlight_device_unregister: name=%s\n", bd->class_dev.class_id);
283 293
294#ifdef CONFIG_PMAC_BACKLIGHT
295 mutex_lock(&pmac_backlight_mutex);
296 if (pmac_backlight == bd)
297 pmac_backlight = NULL;
298 mutex_unlock(&pmac_backlight_mutex);
299#endif
300
284 for (i = 0; i < ARRAY_SIZE(bl_class_device_attributes); i++) 301 for (i = 0; i < ARRAY_SIZE(bl_class_device_attributes); i++)
285 class_device_remove_file(&bd->class_dev, 302 class_device_remove_file(&bd->class_dev,
286 &bl_class_device_attributes[i]); 303 &bl_class_device_attributes[i]);
diff --git a/drivers/video/nvidia/nv_backlight.c b/drivers/video/nvidia/nv_backlight.c
index 2bebfeeb4f1d..0e2bc519dcab 100644
--- a/drivers/video/nvidia/nv_backlight.c
+++ b/drivers/video/nvidia/nv_backlight.c
@@ -16,11 +16,6 @@
16#include "nv_type.h" 16#include "nv_type.h"
17#include "nv_proto.h" 17#include "nv_proto.h"
18 18
19#ifdef CONFIG_PMAC_BACKLIGHT
20#include <asm/backlight.h>
21#include <asm/machdep.h>
22#endif
23
24/* We do not have any information about which values are allowed, thus 19/* We do not have any information about which values are allowed, thus
25 * we used safe values. 20 * we used safe values.
26 */ 21 */
@@ -128,13 +123,6 @@ void nvidia_bl_init(struct nvidia_par *par)
128 bd->props->power = FB_BLANK_UNBLANK; 123 bd->props->power = FB_BLANK_UNBLANK;
129 backlight_update_status(bd); 124 backlight_update_status(bd);
130 125
131#ifdef CONFIG_PMAC_BACKLIGHT
132 mutex_lock(&pmac_backlight_mutex);
133 if (!pmac_backlight)
134 pmac_backlight = bd;
135 mutex_unlock(&pmac_backlight_mutex);
136#endif
137
138 printk("nvidia: Backlight initialized (%s)\n", name); 126 printk("nvidia: Backlight initialized (%s)\n", name);
139 127
140 return; 128 return;
@@ -148,15 +136,6 @@ void nvidia_bl_exit(struct nvidia_par *par)
148 struct fb_info *info = pci_get_drvdata(par->pci_dev); 136 struct fb_info *info = pci_get_drvdata(par->pci_dev);
149 struct backlight_device *bd = info->bl_dev; 137 struct backlight_device *bd = info->bl_dev;
150 138
151 if (bd) { 139 backlight_device_unregister(bd);
152#ifdef CONFIG_PMAC_BACKLIGHT 140 printk("nvidia: Backlight unloaded\n");
153 mutex_lock(&pmac_backlight_mutex);
154 if (pmac_backlight == bd)
155 pmac_backlight = NULL;
156 mutex_unlock(&pmac_backlight_mutex);
157#endif
158 backlight_device_unregister(bd);
159
160 printk("nvidia: Backlight unloaded\n");
161 }
162} 141}
diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c
index ab00350907dd..3a75def01b28 100644
--- a/drivers/video/riva/fbdev.c
+++ b/drivers/video/riva/fbdev.c
@@ -371,13 +371,6 @@ static void riva_bl_init(struct riva_par *par)
371 bd->props->power = FB_BLANK_UNBLANK; 371 bd->props->power = FB_BLANK_UNBLANK;
372 backlight_update_status(bd); 372 backlight_update_status(bd);
373 373
374#ifdef CONFIG_PMAC_BACKLIGHT
375 mutex_lock(&pmac_backlight_mutex);
376 if (!pmac_backlight)
377 pmac_backlight = bd;
378 mutex_unlock(&pmac_backlight_mutex);
379#endif
380
381 printk("riva: Backlight initialized (%s)\n", name); 374 printk("riva: Backlight initialized (%s)\n", name);
382 375
383 return; 376 return;
@@ -390,17 +383,8 @@ static void riva_bl_exit(struct fb_info *info)
390{ 383{
391 struct backlight_device *bd = info->bl_dev; 384 struct backlight_device *bd = info->bl_dev;
392 385
393 if (bd) { 386 backlight_device_unregister(bd);
394#ifdef CONFIG_PMAC_BACKLIGHT 387 printk("riva: Backlight unloaded\n");
395 mutex_lock(&pmac_backlight_mutex);
396 if (pmac_backlight == bd)
397 pmac_backlight = NULL;
398 mutex_unlock(&pmac_backlight_mutex);
399#endif
400 backlight_device_unregister(bd);
401
402 printk("riva: Backlight unloaded\n");
403 }
404} 388}
405#else 389#else
406static inline void riva_bl_init(struct riva_par *par) {} 390static inline void riva_bl_init(struct riva_par *par) {}