diff options
author | Seth Forshee <seth.forshee@canonical.com> | 2012-03-16 15:41:21 -0400 |
---|---|---|
committer | Matthew Garrett <mjg@redhat.com> | 2012-03-22 09:31:55 -0400 |
commit | 83e72dd97a25a831ff270ce4437416943a1e4b36 (patch) | |
tree | 9eeaaa019cc92527469d2976238c1443eadeab21 | |
parent | f11f999e989061952f1a27bd0c49645a46d13173 (diff) |
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>
-rw-r--r-- | drivers/video/backlight/apple_bl.c | 23 | ||||
-rw-r--r-- | include/linux/apple_bl.h | 26 |
2 files changed, 47 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 @@ | |||
24 | #include <linux/io.h> | 24 | #include <linux/io.h> |
25 | #include <linux/pci.h> | 25 | #include <linux/pci.h> |
26 | #include <linux/acpi.h> | 26 | #include <linux/acpi.h> |
27 | #include <linux/atomic.h> | ||
27 | 28 | ||
28 | static struct backlight_device *apple_backlight_device; | 29 | static struct backlight_device *apple_backlight_device; |
29 | 30 | ||
@@ -221,14 +222,32 @@ static struct acpi_driver apple_bl_driver = { | |||
221 | }, | 222 | }, |
222 | }; | 223 | }; |
223 | 224 | ||
225 | static atomic_t apple_bl_registered = ATOMIC_INIT(0); | ||
226 | |||
227 | int apple_bl_register(void) | ||
228 | { | ||
229 | if (atomic_xchg(&apple_bl_registered, 1) == 0) | ||
230 | return acpi_bus_register_driver(&apple_bl_driver); | ||
231 | |||
232 | return 0; | ||
233 | } | ||
234 | EXPORT_SYMBOL_GPL(apple_bl_register); | ||
235 | |||
236 | void apple_bl_unregister(void) | ||
237 | { | ||
238 | if (atomic_xchg(&apple_bl_registered, 0) == 1) | ||
239 | acpi_bus_unregister_driver(&apple_bl_driver); | ||
240 | } | ||
241 | EXPORT_SYMBOL_GPL(apple_bl_unregister); | ||
242 | |||
224 | static int __init apple_bl_init(void) | 243 | static int __init apple_bl_init(void) |
225 | { | 244 | { |
226 | return acpi_bus_register_driver(&apple_bl_driver); | 245 | return apple_bl_register(); |
227 | } | 246 | } |
228 | 247 | ||
229 | static void __exit apple_bl_exit(void) | 248 | static void __exit apple_bl_exit(void) |
230 | { | 249 | { |
231 | acpi_bus_unregister_driver(&apple_bl_driver); | 250 | apple_bl_unregister(); |
232 | } | 251 | } |
233 | 252 | ||
234 | module_init(apple_bl_init); | 253 | module_init(apple_bl_init); |
diff --git a/include/linux/apple_bl.h b/include/linux/apple_bl.h new file mode 100644 index 000000000000..47bedc0eee69 --- /dev/null +++ b/include/linux/apple_bl.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* | ||
2 | * apple_bl exported symbols | ||
3 | */ | ||
4 | |||
5 | #ifndef _LINUX_APPLE_BL_H | ||
6 | #define _LINUX_APPLE_BL_H | ||
7 | |||
8 | #ifdef CONFIG_BACKLIGHT_APPLE | ||
9 | |||
10 | extern int apple_bl_register(void); | ||
11 | extern void apple_bl_unregister(void); | ||
12 | |||
13 | #else /* !CONFIG_BACKLIGHT_APPLE */ | ||
14 | |||
15 | static inline int apple_bl_register(void) | ||
16 | { | ||
17 | return 0; | ||
18 | } | ||
19 | |||
20 | static inline void apple_bl_unregister(void) | ||
21 | { | ||
22 | } | ||
23 | |||
24 | #endif /* !CONFIG_BACKLIGHT_APPLE */ | ||
25 | |||
26 | #endif /* _LINUX_APPLE_BL_H */ | ||