From patchwork Thu Dec 10 13:18:15 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anisse Astier X-Patchwork-Id: 66247 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nBADRjwD017979 for ; Thu, 10 Dec 2009 13:27:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759357AbZLJN1h (ORCPT ); Thu, 10 Dec 2009 08:27:37 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759351AbZLJN1h (ORCPT ); Thu, 10 Dec 2009 08:27:37 -0500 Received: from mail-ew0-f219.google.com ([209.85.219.219]:42837 "EHLO mail-ew0-f219.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759335AbZLJN1g (ORCPT ); Thu, 10 Dec 2009 08:27:36 -0500 Received: by mail-ew0-f219.google.com with SMTP id 19so4303361ewy.21 for ; Thu, 10 Dec 2009 05:27:42 -0800 (PST) Received: by 10.213.51.3 with SMTP id b3mr303690ebg.31.1260451662208; Thu, 10 Dec 2009 05:27:42 -0800 (PST) Received: from localhost.localdomain (253.175.70-86.rev.gaoland.net [86.70.175.253]) by mx.google.com with ESMTPS id 14sm508811ewy.11.2009.12.10.05.27.41 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 10 Dec 2009 05:27:41 -0800 (PST) From: Anisse Astier To: linux-acpi@vger.kernel.org, linux-input@vger.kernel.org Cc: Dmitry Torokhov , Len Brown , Matthew Garrett , Thomas Renninger , Carlos Corbacho , Matt Chen , Anisse Astier Subject: [PATCH 3/7] msi-wmi: rework init Date: Thu, 10 Dec 2009 14:18:15 +0100 Message-Id: <1260451099-25620-4-git-send-email-anisse@astier.eu> X-Mailer: git-send-email 1.6.5.3 In-Reply-To: <1260451099-25620-1-git-send-email-anisse@astier.eu> References: <1260451099-25620-1-git-send-email-anisse@astier.eu> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c index fb988d8..dcb048c 100644 --- a/drivers/platform/x86/msi-wmi.c +++ b/drivers/platform/x86/msi-wmi.c @@ -284,6 +284,8 @@ static int __init msi_wmi_input_setup(void) int err; msi_wmi_input_dev = input_allocate_device(); + if (!msi_wmi_input_dev) + return -ENOMEM; msi_wmi_input_dev->name = "MSI WMI hotkeys"; msi_wmi_input_dev->phys = "wmi/input0"; @@ -314,40 +316,44 @@ static int __init msi_wmi_init(void) { int err; - if (wmi_has_guid(MSIWMI_EVENT_GUID)) { - err = wmi_install_notify_handler(MSIWMI_EVENT_GUID, - msi_wmi_notify, NULL); - if (err) - return -EINVAL; - - err = msi_wmi_input_setup(); - if (err) { - wmi_remove_notify_handler(MSIWMI_EVENT_GUID); - return -EINVAL; - } + if (!wmi_has_guid(MSIWMI_EVENT_GUID)) { + printk(KERN_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 (err) + return -EINVAL; - if (!acpi_video_backlight_support()) { - backlight = backlight_device_register(DRV_NAME, - NULL, NULL, &msi_backlight_ops); - if (IS_ERR(backlight)) { - wmi_remove_notify_handler(MSIWMI_EVENT_GUID); - input_unregister_device(msi_wmi_input_dev); - return -EINVAL; - } + err = msi_wmi_input_setup(); + if (err) + goto err_uninstall_notifier; - backlight->props.max_brightness = ARRAY_SIZE(backlight_map) - 1; - err = bl_get(NULL); - if (err < 0) { - wmi_remove_notify_handler(MSIWMI_EVENT_GUID); - input_unregister_device(msi_wmi_input_dev); - backlight_device_unregister(backlight); - return -EINVAL; - } - backlight->props.brightness = err; - } + if (!acpi_video_backlight_support()) { + backlight = backlight_device_register(DRV_NAME, + NULL, NULL, &msi_backlight_ops); + if (IS_ERR(backlight)) + goto err_free_input; + + backlight->props.max_brightness = ARRAY_SIZE(backlight_map) - 1; + err = bl_get(NULL); + if (err < 0) + goto err_free_backlight; + + backlight->props.brightness = err; } printk(KERN_INFO DRV_PFX "Event handler installed\n"); + return 0; + +err_free_backlight: + backlight_device_unregister(backlight); +err_free_input: + input_unregister_device(msi_wmi_input_dev); +err_uninstall_notifier: + wmi_remove_notify_handler(MSIWMI_EVENT_GUID); + return err; } static void __exit msi_wmi_exit(void)