提交 83e72dd9 编写于 作者: S Seth Forshee 提交者: Matthew Garrett

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: NSeth Forshee <seth.forshee@canonical.com>
Signed-off-by: NMatthew Garrett <mjg@redhat.com>
上级 f11f999e
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/atomic.h>
static struct backlight_device *apple_backlight_device; static struct backlight_device *apple_backlight_device;
...@@ -221,15 +222,33 @@ static struct acpi_driver apple_bl_driver = { ...@@ -221,15 +222,33 @@ static struct acpi_driver apple_bl_driver = {
}, },
}; };
static int __init apple_bl_init(void) 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 acpi_bus_register_driver(&apple_bl_driver);
return 0;
} }
EXPORT_SYMBOL_GPL(apple_bl_register);
static void __exit apple_bl_exit(void) void apple_bl_unregister(void)
{ {
if (atomic_xchg(&apple_bl_registered, 0) == 1)
acpi_bus_unregister_driver(&apple_bl_driver); acpi_bus_unregister_driver(&apple_bl_driver);
} }
EXPORT_SYMBOL_GPL(apple_bl_unregister);
static int __init apple_bl_init(void)
{
return apple_bl_register();
}
static void __exit apple_bl_exit(void)
{
apple_bl_unregister();
}
module_init(apple_bl_init); module_init(apple_bl_init);
module_exit(apple_bl_exit); module_exit(apple_bl_exit);
......
/*
* 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 */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册