From patchwork Wed Oct 12 23:32:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chun-Yi Lee X-Patchwork-Id: 9374187 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EB42B60839 for ; Thu, 13 Oct 2016 03:51:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6AAB29823 for ; Thu, 13 Oct 2016 03:51:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB3012982F; Thu, 13 Oct 2016 03:51:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2758C29823 for ; Thu, 13 Oct 2016 03:51:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933961AbcJMDva (ORCPT ); Wed, 12 Oct 2016 23:51:30 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:35496 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933767AbcJMDv3 (ORCPT ); Wed, 12 Oct 2016 23:51:29 -0400 Received: by mail-pf0-f193.google.com with SMTP id s8so4076389pfj.2; Wed, 12 Oct 2016 20:51:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=OeiKsBdsYAenfFyZHmd9A47cCMF5RVR4MOTwAHGZuKk=; b=sPprCV9MO7vjM8W/L3NfB2tQUx5++Ty/NesFwTDKai9Xpbub+uFzIeszPceQ2UtFNB YlvvnVFkD6vsd7TFrYNvWvnzod8dp7xc2j4InzBIqoIlDC7qRmp2NaYeGVXpAN/5sMOo Mt+LOjZ6F5luqZOF2HQ6QnWeIMiAFUVfMguX1EQYoXicQ8dMxoR2ESD0G4YrbRA8jTL4 TdfFnRSySybeqJOALINe+7uxeZ7ApRi9ChxEmcUK0AcKFlmDfGrT3ohA0Tpog1wnFBN0 MxlQInQytpAfFR/Url6Z4b3OVK3WTCUQ3ULeiK+liH6b7KGQpcahYInw4BC9CsJFxQ2+ HijA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=OeiKsBdsYAenfFyZHmd9A47cCMF5RVR4MOTwAHGZuKk=; b=Hd5dtL7Nhiy8MOUCs/lDPOhGQiaQKtumq6HkJH9VdQ1iPVf+ctQfyUdvVT3Zidx15W K/MHVXDgR6+fQA99MWnHl7n0oqqVnvdvGZb6BuMnhRxKiWIhB7biWMUNbOpBAguayQHs RQQjtL/jFF9bSnoop09C8eeOpsA/riHsIABT4mS02jXuWJ3o/KmYjwU3feUxV6CuTeJD aowS0wehSKy3Tx90VapsXT7tucKSbU1Phra7+YCbJoLFmqAwXmzeU/91uM3GN/6mIniY 4GbwYeGq4/zxEwR5XQlI0CvboFYS69543ulWjJUViJjaE+2u4ecb0V9KjdpaXO9e3Dno mY2Q== X-Gm-Message-State: AA6/9RnDLVT3U3xV7M0EOT+EKMgpmf4sgU7EIEFLcm9JRk82j2HPaS4sknCDS5nXfQaDiQ== X-Received: by 10.98.36.219 with SMTP id k88mr5522666pfk.88.1476315349392; Wed, 12 Oct 2016 16:35:49 -0700 (PDT) Received: from linux-rxt1.site ([124.11.22.254]) by smtp.gmail.com with ESMTPSA id z123sm14285475pfz.60.2016.10.12.16.35.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Oct 2016 16:35:48 -0700 (PDT) From: "Lee, Chun-Yi" X-Google-Original-From: "Lee, Chun-Yi" To: Darren Hart Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, "Lee, Chun-Yi" Subject: [PATCH] acer-wmi: setup accelerometer when machine has appropriate notify event Date: Thu, 13 Oct 2016 07:32:20 +0800 Message-Id: <1476315140-20443-1-git-send-email-jlee@suse.com> X-Mailer: git-send-email 1.8.4.5 MIME-Version: 1.0 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The accelerometer event relies on on the ACERWMID_EVENT_GUID notify. So, this patch changes the codes to setup accelerometer input device when detected ACERWMID_EVENT_GUID. It avoids that the accel input device created on every acer machines. In addition, patch adds a clearly parsing logic of accelerometer hid to acer_wmi_get_handle_cb callback function. It is positive matching the "SENR" name with "BST0001" device to avoid non-supported hardware. Reported-by: Bjørn Mork Tested-by: Bjørn Mork Cc: Darren Hart Signed-off-by: Lee, Chun-Yi --- drivers/platform/x86/acer-wmi.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index 79d64ea..3bb3162 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1808,11 +1808,24 @@ static int __init acer_wmi_enable_lm(void) return status; } +#define ACER_WMID_ACCEL_HID "BST0001" + static acpi_status __init acer_wmi_get_handle_cb(acpi_handle ah, u32 level, void *ctx, void **retval) { + struct acpi_device *dev; + + if (strcmp(ctx, "SENR")) { + if (acpi_bus_get_device(ah, &dev)) + return AE_OK; + if (!strcmp(ACER_WMID_ACCEL_HID, acpi_device_hid(dev))) + return AE_OK; + } else + return AE_OK; + *(acpi_handle *)retval = ah; - return AE_OK; + + return AE_CTRL_TERMINATE; } static int __init acer_wmi_get_handle(const char *name, const char *prop, @@ -1839,7 +1852,7 @@ static int __init acer_wmi_accel_setup(void) { int err; - err = acer_wmi_get_handle("SENR", "BST0001", &gsensor_handle); + err = acer_wmi_get_handle("SENR", ACER_WMID_ACCEL_HID, &gsensor_handle); if (err) return err; @@ -2177,10 +2190,11 @@ static int __init acer_wmi_init(void) err = acer_wmi_input_setup(); if (err) return err; + err = acer_wmi_accel_setup(); + if (err) + return err; } - acer_wmi_accel_setup(); - err = platform_driver_register(&acer_platform_driver); if (err) { pr_err("Unable to register platform driver\n");