From: joeyli <jlee@suse.com>
To: Maxim Mikityanskiy <maxtram95@gmail.com>
Cc: platform-driver-x86@vger.kernel.org, anisse@astier.eu
Subject: Re: [PATCH v4 10/12] msi-wmi: Make keys and backlight independent
Date: Mon, 17 Dec 2012 17:04:20 +0800 [thread overview]
Message-ID: <1355735060.2710.87.camel@linux-s257.site> (raw)
In-Reply-To: <1355592696-15454-11-git-send-email-maxtram95@gmail.com>
於 六,2012-12-15 於 19:31 +0200,Maxim Mikityanskiy 提到:
> Introduced function msi_wmi_backlight_setup() that initializes backlight
> device. Made driver load and work if only one WMI (only for hotkeys or
> only for backlight) is present.
>
> Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com>
Acked-by: Lee, Chun-Yi <jlee@suse.com>
Thanks a lot!
Joey Lee
> ---
> drivers/platform/x86/msi-wmi.c | 101 ++++++++++++++++++++++++++---------------
> 1 file changed, 64 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
> index 112ec14..3a60619 100644
> --- a/drivers/platform/x86/msi-wmi.c
> +++ b/drivers/platform/x86/msi-wmi.c
> @@ -60,6 +60,8 @@ static struct key_entry msi_wmi_keymap[] = {
> };
> static ktime_t last_pressed[ARRAY_SIZE(msi_wmi_keymap) - 1];
>
> +static const char *event_wmi_guid;
> +
> static struct backlight_device *backlight;
>
> static int backlight_map[] = { 0x00, 0x33, 0x66, 0x99, 0xCC, 0xFF };
> @@ -184,7 +186,7 @@ static void msi_wmi_notify(u32 value, void *context)
>
> if (key->type == KE_KEY &&
> /* Brightness is served via acpi video driver */
> - (!acpi_video_backlight_support() ||
> + (backlight ||
> (key->code != MSI_KEY_BRIGHTNESSUP &&
> key->code != MSI_KEY_BRIGHTNESSDOWN))) {
> pr_debug("Send key: 0x%X - "
> @@ -202,6 +204,31 @@ msi_wmi_notify_exit:
> kfree(response.pointer);
> }
>
> +static int __init msi_wmi_backlight_setup(void)
> +{
> + int err;
> + struct backlight_properties props;
> +
> + memset(&props, 0, sizeof(struct backlight_properties));
> + props.type = BACKLIGHT_PLATFORM;
> + props.max_brightness = ARRAY_SIZE(backlight_map) - 1;
> + backlight = backlight_device_register(DRV_NAME, NULL, NULL,
> + &msi_backlight_ops,
> + &props);
> + if (IS_ERR(backlight))
> + return PTR_ERR(backlight);
> +
> + err = bl_get(NULL);
> + if (err < 0) {
> + backlight_device_unregister(backlight);
> + return err;
> + }
> +
> + backlight->props.brightness = err;
> +
> + return 0;
> +}
> +
> static int __init msi_wmi_input_setup(void)
> {
> int err;
> @@ -238,60 +265,60 @@ static int __init msi_wmi_init(void)
> {
> int err;
>
> - if (!wmi_has_guid(MSIWMI_EVENT_GUID)) {
> - pr_err("This machine doesn't have MSI-hotkeys through WMI\n");
> - return -ENODEV;
> - }
> - err = wmi_install_notify_handler(MSIWMI_EVENT_GUID,
> - msi_wmi_notify, NULL);
> - if (ACPI_FAILURE(err))
> - return -EINVAL;
> + if (wmi_has_guid(MSIWMI_EVENT_GUID)) {
> + err = msi_wmi_input_setup();
> + if (err) {
> + pr_err("Unable to setup input device\n");
> + return err;
> + }
>
> - err = msi_wmi_input_setup();
> - if (err)
> - goto err_uninstall_notifier;
> -
> - if (!acpi_video_backlight_support()) {
> - struct backlight_properties props;
> - memset(&props, 0, sizeof(struct backlight_properties));
> - props.type = BACKLIGHT_PLATFORM;
> - props.max_brightness = ARRAY_SIZE(backlight_map) - 1;
> - backlight = backlight_device_register(DRV_NAME, NULL, NULL,
> - &msi_backlight_ops,
> - &props);
> - if (IS_ERR(backlight)) {
> - err = PTR_ERR(backlight);
> + err = wmi_install_notify_handler(MSIWMI_EVENT_GUID,
> + msi_wmi_notify, NULL);
> + if (ACPI_FAILURE(err)) {
> + pr_err("Unable to setup WMI notify handler\n");
> goto err_free_input;
> }
>
> - err = bl_get(NULL);
> - if (err < 0)
> - goto err_free_backlight;
> + pr_debug("Event handler installed\n");
> + event_wmi_guid = MSIWMI_EVENT_GUID;
> + }
> +
> + if (wmi_has_guid(MSIWMI_BIOS_GUID) && !acpi_video_backlight_support()) {
> + err = msi_wmi_backlight_setup();
> + if (err) {
> + pr_err("Unable to setup backlight device\n");
> + goto err_uninstall_handler;
> + }
> + pr_debug("Backlight device created\n");
> + }
>
> - backlight->props.brightness = err;
> + if (!event_wmi_guid && !backlight) {
> + pr_err("This machine doesn't have neither MSI-hotkeys nor backlight through WMI\n");
> + return -ENODEV;
> }
> - pr_debug("Event handler installed\n");
>
> return 0;
>
> -err_free_backlight:
> - backlight_device_unregister(backlight);
> +err_uninstall_handler:
> + if (event_wmi_guid)
> + wmi_remove_notify_handler(event_wmi_guid);
> err_free_input:
> - sparse_keymap_free(msi_wmi_input_dev);
> - input_unregister_device(msi_wmi_input_dev);
> -err_uninstall_notifier:
> - wmi_remove_notify_handler(MSIWMI_EVENT_GUID);
> + if (event_wmi_guid) {
> + sparse_keymap_free(msi_wmi_input_dev);
> + input_unregister_device(msi_wmi_input_dev);
> + }
> return err;
> }
>
> static void __exit msi_wmi_exit(void)
> {
> - if (wmi_has_guid(MSIWMI_EVENT_GUID)) {
> - wmi_remove_notify_handler(MSIWMI_EVENT_GUID);
> + if (event_wmi_guid) {
> + wmi_remove_notify_handler(event_wmi_guid);
> sparse_keymap_free(msi_wmi_input_dev);
> input_unregister_device(msi_wmi_input_dev);
> - backlight_device_unregister(backlight);
> }
> + if (backlight)
> + backlight_device_unregister(backlight);
> }
>
> module_init(msi_wmi_init);
next prev parent reply other threads:[~2012-12-17 9:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-15 17:31 [PATCH v4 00/12] Add MSI Wind U90/U100 support Maxim Mikityanskiy
2012-12-15 17:31 ` [PATCH v4 01/12] msi-laptop: Use proper return codes instead of -1 Maxim Mikityanskiy
2012-12-15 17:31 ` [PATCH v4 02/12] msi-laptop: Work around gcc warning Maxim Mikityanskiy
2012-12-15 17:31 ` [PATCH v4 03/12] msi-laptop: merge quirk tables to one Maxim Mikityanskiy
2012-12-15 17:31 ` [PATCH v4 04/12] msi-laptop: Add MSI Wind U90/U100 support Maxim Mikityanskiy
2012-12-15 17:31 ` [PATCH v4 05/12] msi-laptop: Add missing ABI documentation Maxim Mikityanskiy
2012-12-15 17:31 ` [PATCH v4 06/12] msi-laptop: Disable brightness control for new EC Maxim Mikityanskiy
2012-12-15 17:31 ` [PATCH v4 07/12] msi-wmi: Fix memory leak Maxim Mikityanskiy
2012-12-15 17:31 ` [PATCH v4 08/12] msi-wmi: Avoid repeating constants Maxim Mikityanskiy
2012-12-20 16:59 ` Anisse Astier
2012-12-15 17:31 ` [PATCH v4 09/12] msi-wmi: Use enums for scancodes Maxim Mikityanskiy
2012-12-20 17:01 ` Anisse Astier
2012-12-15 17:31 ` [PATCH v4 10/12] msi-wmi: Make keys and backlight independent Maxim Mikityanskiy
2012-12-17 9:04 ` joeyli [this message]
2012-12-20 17:01 ` Anisse Astier
2012-12-15 17:31 ` [PATCH v4 11/12] msi-wmi: Introduced quirk_last_pressed Maxim Mikityanskiy
2012-12-17 9:56 ` joeyli
2012-12-20 17:02 ` Anisse Astier
2012-12-15 17:31 ` [PATCH v4 12/12] msi-wmi: Add MSI Wind support Maxim Mikityanskiy
2012-12-17 10:00 ` joeyli
2012-12-20 17:02 ` Anisse Astier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1355735060.2710.87.camel@linux-s257.site \
--to=jlee@suse.com \
--cc=anisse@astier.eu \
--cc=maxtram95@gmail.com \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox