]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/video/backlight/backlight.c
backlight: Clean up pmac_backlight handling
[linux-2.6-omap-h63xx.git] / drivers / video / backlight / backlight.c
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]);