aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorSeth Forshee <seth.forshee@canonical.com>2012-03-16 14:41:21 -0500
committerMatthew Garrett <mjg@redhat.com>2012-03-22 09:31:55 -0400
commit83e72dd97a25a831ff270ce4437416943a1e4b36 (patch)
tree9eeaaa019cc92527469d2976238c1443eadeab21 /drivers/video
parenttoshiba_acpi: Refuse to load on machines with buggy INFO implementations (diff)
downloadlinux-dev-83e72dd97a25a831ff270ce4437416943a1e4b36.tar.xz
linux-dev-83e72dd97a25a831ff270ce4437416943a1e4b36.zip
apple_bl: Add register/unregister functions
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>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/backlight/apple_bl.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/drivers/video/backlight/apple_bl.c b/drivers/video/backlight/apple_bl.c
index be98d152b7fd..a523b255e124 100644
--- a/drivers/video/backlight/apple_bl.c
+++ b/drivers/video/backlight/apple_bl.c
@@ -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);