From patchwork Wed Mar 21 19:13:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 148060 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 30A5DB6FDA for ; Thu, 22 Mar 2012 06:13:22 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SAQy6-000487-6d; Wed, 21 Mar 2012 19:13:10 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SAQy3-00047v-TT for kernel-team@lists.ubuntu.com; Wed, 21 Mar 2012 19:13:07 +0000 Received: from 64-126-113-183.dyn.everestkc.net ([64.126.113.183] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1SAQy3-0000Gj-Ke for kernel-team@lists.ubuntu.com; Wed, 21 Mar 2012 19:13:07 +0000 From: Seth Forshee To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/2][Precise] UBUNTU: SAUCE: (drop after 3.3) apple_bl: Add register/unregister functions Date: Wed, 21 Mar 2012 14:13:02 -0500 Message-Id: <1332357183-17055-2-git-send-email-seth.forshee@canonical.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1332357183-17055-1-git-send-email-seth.forshee@canonical.com> References: <1332357183-17055-1-git-send-email-seth.forshee@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com 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 --- drivers/video/backlight/apple_bl.c | 23 +++++++++++++++++++++-- include/linux/apple_bl.h | 26 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 include/linux/apple_bl.h diff --git a/drivers/video/backlight/apple_bl.c b/drivers/video/backlight/apple_bl.c index be98d15..a523b25 100644 --- a/drivers/video/backlight/apple_bl.c +++ b/drivers/video/backlight/apple_bl.c @@ -24,6 +24,7 @@ #include #include #include +#include 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 index 0000000..47bedc0 --- /dev/null +++ b/include/linux/apple_bl.h @@ -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 */