]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
apple_bl: Add register/unregister functions
authorSeth Forshee <seth.forshee@canonical.com>
Fri, 16 Mar 2012 19:41:21 +0000 (14:41 -0500)
committerMatthew Garrett <mjg@redhat.com>
Thu, 22 Mar 2012 13:31:55 +0000 (09:31 -0400)
Add functions to allow other modules to enable or disable apple_bl. This
will be used by the gmux driver to disable apple_bl when the gmux is
present, as it is a better and more reliable option for brightness
control.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
drivers/video/backlight/apple_bl.c
include/linux/apple_bl.h [new file with mode: 0644]

index be98d152b7fd9e798d0112e0a95192ebec57d56c..a523b255e124cc3ff44e4b39d15c9ba4a6f5761a 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/io.h>
 #include <linux/pci.h>
 #include <linux/acpi.h>
+#include <linux/atomic.h>
 
 static struct backlight_device *apple_backlight_device;
 
@@ -221,14 +222,32 @@ static struct acpi_driver apple_bl_driver = {
        },
 };
 
+static atomic_t apple_bl_registered = ATOMIC_INIT(0);
+
+int apple_bl_register(void)
+{
+       if (atomic_xchg(&apple_bl_registered, 1) == 0)
+               return acpi_bus_register_driver(&apple_bl_driver);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(apple_bl_register);
+
+void apple_bl_unregister(void)
+{
+       if (atomic_xchg(&apple_bl_registered, 0) == 1)
+               acpi_bus_unregister_driver(&apple_bl_driver);
+}
+EXPORT_SYMBOL_GPL(apple_bl_unregister);
+
 static int __init apple_bl_init(void)
 {
-       return acpi_bus_register_driver(&apple_bl_driver);
+       return apple_bl_register();
 }
 
 static void __exit apple_bl_exit(void)
 {
-       acpi_bus_unregister_driver(&apple_bl_driver);
+       apple_bl_unregister();
 }
 
 module_init(apple_bl_init);
diff --git a/include/linux/apple_bl.h b/include/linux/apple_bl.h
new file mode 100644 (file)
index 0000000..47bedc0
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * apple_bl exported symbols
+ */
+
+#ifndef _LINUX_APPLE_BL_H
+#define _LINUX_APPLE_BL_H
+
+#ifdef CONFIG_BACKLIGHT_APPLE
+
+extern int apple_bl_register(void);
+extern void apple_bl_unregister(void);
+
+#else /* !CONFIG_BACKLIGHT_APPLE */
+
+static inline int apple_bl_register(void)
+{
+       return 0;
+}
+
+static inline void apple_bl_unregister(void)
+{
+}
+
+#endif /* !CONFIG_BACKLIGHT_APPLE */
+
+#endif /* _LINUX_APPLE_BL_H */