]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
backlight: Clean up pmac_backlight handling
authorRichard Purdie <rpurdie@rpsys.net>
Sat, 10 Feb 2007 15:04:08 +0000 (15:04 +0000)
committerRichard Purdie <rpurdie@rpsys.net>
Tue, 20 Feb 2007 09:26:40 +0000 (09:26 +0000)
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>
drivers/macintosh/via-pmu-backlight.c
drivers/misc/sony-laptop.c
drivers/video/aty/aty128fb.c
drivers/video/aty/atyfb_base.c
drivers/video/aty/radeon_backlight.c
drivers/video/backlight/backlight.c
drivers/video/nvidia/nv_backlight.c
drivers/video/riva/fbdev.c

index 7ba2042b2dd0ea354d6764af5d7a0d496f4fa026..9f9d03127978d8662fd91b9e2f88386e157e79ef 100644 (file)
@@ -170,11 +170,6 @@ void __init pmu_backlight_init()
        bd->props->power = FB_BLANK_UNBLANK;
        backlight_update_status(bd);
 
-       mutex_lock(&pmac_backlight_mutex);
-       if (!pmac_backlight)
-               pmac_backlight = bd;
-       mutex_unlock(&pmac_backlight_mutex);
-
        printk("pmubl: Backlight initialized (%s)\n", name);
 
        return;
index 03d02bd9f122e698ab34c5cc97ab09fcdd49a53c..2ebe240dd53761f236007f0dd17fc46a09db26ad 100644 (file)
@@ -384,7 +384,7 @@ static void sony_snc_pf_remove(void)
 static int sony_backlight_update_status(struct backlight_device *bd)
 {
        return acpi_callsetfunc(sony_acpi_handle, "SBRT",
-                               bd->props->brightness + 1, NULL);
+                               bd->props.brightness + 1, NULL);
 }
 
 static int sony_backlight_get_brightness(struct backlight_device *bd)
@@ -398,10 +398,9 @@ static int sony_backlight_get_brightness(struct backlight_device *bd)
 }
 
 static struct backlight_device *sony_backlight_device;
-static struct backlight_properties sony_backlight_properties = {
+static struct backlight_ops sony_backlight_ops = {
        .update_status = sony_backlight_update_status,
        .get_brightness = sony_backlight_get_brightness,
-       .max_brightness = SONY_MAX_BRIGHTNESS - 1,
 };
 
 /*
@@ -483,15 +482,19 @@ static int sony_acpi_add(struct acpi_device *device)
        if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, "GBRT", &handle))) {
                sony_backlight_device = backlight_device_register("sony", NULL,
                                                                  NULL,
-                                                                 &sony_backlight_properties);
+                                                                 &sony_backlight_ops);
 
                if (IS_ERR(sony_backlight_device)) {
                        printk(LOG_PFX "unable to register backlight device\n");
                        sony_backlight_device = NULL;
-               } else
-                       sony_backlight_properties.brightness =
+               } else {
+                       sony_backlight_device->props.brightness =
                            sony_backlight_get_brightness
                            (sony_backlight_device);
+                       sony_backlight_device->props.max_brightness = 
+                           SONY_MAX_BRIGHTNESS - 1;
+               }
+
        }
 
        if (sony_snc_pf_add())
index ef3e7861c27a8f2a40512ca9e618d1e3f020401c..4de8d6252c3c563634274d0cadd6239a3074388d 100644 (file)
@@ -1829,13 +1829,6 @@ static void aty128_bl_init(struct aty128fb_par *par)
        bd->props->power = FB_BLANK_UNBLANK;
        backlight_update_status(bd);
 
-#ifdef CONFIG_PMAC_BACKLIGHT
-       mutex_lock(&pmac_backlight_mutex);
-       if (!pmac_backlight)
-               pmac_backlight = bd;
-       mutex_unlock(&pmac_backlight_mutex);
-#endif
-
        printk("aty128: Backlight initialized (%s)\n", name);
 
        return;
@@ -1846,17 +1839,8 @@ error:
 
 static void aty128_bl_exit(struct backlight_device *bd)
 {
-       if (bd) {
-#ifdef CONFIG_PMAC_BACKLIGHT
-               mutex_lock(&pmac_backlight_mutex);
-               if (pmac_backlight == bd)
-                       pmac_backlight = NULL;
-               mutex_unlock(&pmac_backlight_mutex);
-#endif
-               backlight_device_unregister(bd);
-
-               printk("aty128: Backlight unloaded\n");
-       }
+       backlight_device_unregister(bd);
+       printk("aty128: Backlight unloaded\n");
 }
 #endif /* CONFIG_FB_ATY128_BACKLIGHT */
 
index 66462286e70484cc7502eb149e1968808c00389f..35ba265675981ed922b410993c4a67a5b2b93551 100644 (file)
@@ -2198,13 +2198,6 @@ static void aty_bl_init(struct atyfb_par *par)
        bd->props->power = FB_BLANK_UNBLANK;
        backlight_update_status(bd);
 
-#ifdef CONFIG_PMAC_BACKLIGHT
-       mutex_lock(&pmac_backlight_mutex);
-       if (!pmac_backlight)
-               pmac_backlight = bd;
-       mutex_unlock(&pmac_backlight_mutex);
-#endif
-
        printk("aty: Backlight initialized (%s)\n", name);
 
        return;
@@ -2215,17 +2208,8 @@ error:
 
 static void aty_bl_exit(struct backlight_device *bd)
 {
-       if (bd) {
-#ifdef CONFIG_PMAC_BACKLIGHT
-               mutex_lock(&pmac_backlight_mutex);
-               if (pmac_backlight == bd)
-                       pmac_backlight = NULL;
-               mutex_unlock(&pmac_backlight_mutex);
-#endif
-               backlight_device_unregister(bd);
-
-               printk("aty: Backlight unloaded\n");
-       }
+       backlight_device_unregister(bd);
+       printk("aty: Backlight unloaded\n");
 }
 
 #endif /* CONFIG_FB_ATY_BACKLIGHT */
index f94e4616788d9761c78ad554f72631474d7d6065..8c775e6a7e03754eafcfaa217093737619fe1585 100644 (file)
@@ -192,13 +192,6 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo)
        bd->props->power = FB_BLANK_UNBLANK;
        backlight_update_status(bd);
 
-#ifdef CONFIG_PMAC_BACKLIGHT
-       mutex_lock(&pmac_backlight_mutex);
-       if (!pmac_backlight)
-               pmac_backlight = bd;
-       mutex_unlock(&pmac_backlight_mutex);
-#endif
-
        printk("radeonfb: Backlight initialized (%s)\n", name);
 
        return;
@@ -215,12 +208,6 @@ void radeonfb_bl_exit(struct radeonfb_info *rinfo)
        if (bd) {
                struct radeon_bl_privdata *pdata;
 
-#ifdef CONFIG_PMAC_BACKLIGHT
-               mutex_lock(&pmac_backlight_mutex);
-               if (pmac_backlight == bd)
-                       pmac_backlight = NULL;
-               mutex_unlock(&pmac_backlight_mutex);
-#endif
                pdata = class_get_devdata(&bd->class_dev);
                backlight_device_unregister(bd);
                kfree(pdata);
index 5490b2ae51342ea8e3a53e4f64e05bf45576a2b9..822a373d334657688802e1d2de1578f0245836ba 100644 (file)
@@ -14,6 +14,9 @@
 #include <linux/err.h>
 #include <linux/fb.h>
 
+#ifdef CONFIG_PMAC_BACKLIGHT
+#include <asm/backlight.h>
+#endif
 
 #if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
                           defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE))
@@ -262,6 +265,13 @@ struct backlight_device *backlight_device_register(const char *name,
                }
        }
 
+#ifdef CONFIG_PMAC_BACKLIGHT
+       mutex_lock(&pmac_backlight_mutex);
+       if (!pmac_backlight)
+               pmac_backlight = new_bd;
+       mutex_unlock(&pmac_backlight_mutex);
+#endif
+
        return new_bd;
 }
 EXPORT_SYMBOL(backlight_device_register);
@@ -281,6 +291,13 @@ void backlight_device_unregister(struct backlight_device *bd)
 
        pr_debug("backlight_device_unregister: name=%s\n", bd->class_dev.class_id);
 
+#ifdef CONFIG_PMAC_BACKLIGHT
+       mutex_lock(&pmac_backlight_mutex);
+       if (pmac_backlight == bd)
+               pmac_backlight = NULL;
+       mutex_unlock(&pmac_backlight_mutex);
+#endif
+
        for (i = 0; i < ARRAY_SIZE(bl_class_device_attributes); i++)
                class_device_remove_file(&bd->class_dev,
                                         &bl_class_device_attributes[i]);
index 2bebfeeb4f1d4e774c372f2218225644db281599..0e2bc519dcabf4e12a31d9df8f4d4b750b6f5f53 100644 (file)
 #include "nv_type.h"
 #include "nv_proto.h"
 
-#ifdef CONFIG_PMAC_BACKLIGHT
-#include <asm/backlight.h>
-#include <asm/machdep.h>
-#endif
-
 /* We do not have any information about which values are allowed, thus
  * we used safe values.
  */
@@ -128,13 +123,6 @@ void nvidia_bl_init(struct nvidia_par *par)
        bd->props->power = FB_BLANK_UNBLANK;
        backlight_update_status(bd);
 
-#ifdef CONFIG_PMAC_BACKLIGHT
-       mutex_lock(&pmac_backlight_mutex);
-       if (!pmac_backlight)
-               pmac_backlight = bd;
-       mutex_unlock(&pmac_backlight_mutex);
-#endif
-
        printk("nvidia: Backlight initialized (%s)\n", name);
 
        return;
@@ -148,15 +136,6 @@ 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);
-               if (pmac_backlight == bd)
-                       pmac_backlight = NULL;
-               mutex_unlock(&pmac_backlight_mutex);
-#endif
-               backlight_device_unregister(bd);
-
-               printk("nvidia: Backlight unloaded\n");
-       }
+       backlight_device_unregister(bd);
+       printk("nvidia: Backlight unloaded\n");
 }
index ab00350907dd390c4b0958fd6f0b311522177929..3a75def01b283714bf6d90422a28bfdbe3708e6e 100644 (file)
@@ -371,13 +371,6 @@ static void riva_bl_init(struct riva_par *par)
        bd->props->power = FB_BLANK_UNBLANK;
        backlight_update_status(bd);
 
-#ifdef CONFIG_PMAC_BACKLIGHT
-       mutex_lock(&pmac_backlight_mutex);
-       if (!pmac_backlight)
-               pmac_backlight = bd;
-       mutex_unlock(&pmac_backlight_mutex);
-#endif
-
        printk("riva: Backlight initialized (%s)\n", name);
 
        return;
@@ -390,17 +383,8 @@ static void riva_bl_exit(struct fb_info *info)
 {
        struct backlight_device *bd = info->bl_dev;
 
-       if (bd) {
-#ifdef CONFIG_PMAC_BACKLIGHT
-               mutex_lock(&pmac_backlight_mutex);
-               if (pmac_backlight == bd)
-                       pmac_backlight = NULL;
-               mutex_unlock(&pmac_backlight_mutex);
-#endif
-               backlight_device_unregister(bd);
-
-               printk("riva: Backlight unloaded\n");
-       }
+       backlight_device_unregister(bd);
+       printk("riva: Backlight unloaded\n");
 }
 #else
 static inline void riva_bl_init(struct riva_par *par) {}