From patchwork Thu Nov 3 00:18:52 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: 9410021 X-Patchwork-Delegate: andy.shevchenko@gmail.com 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 36A7260721 for ; Thu, 3 Nov 2016 00:21:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1978F2A6AD for ; Thu, 3 Nov 2016 00:21:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B9D22A6BB; Thu, 3 Nov 2016 00:21:01 +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 11B862A6AD for ; Thu, 3 Nov 2016 00:21:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750824AbcKCAU7 (ORCPT ); Wed, 2 Nov 2016 20:20:59 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35185 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750723AbcKCAU6 (ORCPT ); Wed, 2 Nov 2016 20:20:58 -0400 Received: by mail-pf0-f196.google.com with SMTP id i88so3036585pfk.2; Wed, 02 Nov 2016 17:20:58 -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=KglrZwO9CChj3Pdct5ftEE9lkb6m7caj6MvP6Iix+3g=; b=Ci/cLQJ1w1/j2eEuMzlefWsd7oDAXsMiUqnPuorGJjSejjr6x8u7bEKaR+F/AngkMk QlZ7LiKgJ7e+aeHBF6suTEH+jj8LuoTH27JbthywPHjxIvhuTcQriPIVwQBchqoMkM0X OMy+ChY09Uxjbe+idn36RLpmJ2HH9KfZfmpCGtMC28Ko8EchS2VeO7Uy/URw2A7KgGAP SE3pf55Ahfv/z/3KL0AHd8QADugeQ7fdmunPP90ThLiGUUVSC1A7VS2g/CSv/lIyMMT/ M767Hgo4ipdSuuTgvTrX9f3ruebWjVAk7hggO5rdUmUHdOqzziYlreVGp9U37lLM7Cgs yDiw== 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=KglrZwO9CChj3Pdct5ftEE9lkb6m7caj6MvP6Iix+3g=; b=Qu7ahc9Chg2m1X3v9urG71zO4XRhogocTN/wFroW5lRYUOd45H0ntOlcLY46rDHqtY QFsu09ps5IpSEOHX0ns8sizodYdnP2CJFBqJy+raTk7FWqJfgNAMu+jYIZydJxLCK8en 3Ozl2C/vaDWFP4T0Wguev5Yur2daL6hOBKiDCsDeVGcnAo1um5CgwGsiXLzSGkG/jNU/ 7SuvmrswO0I+aYUEyx65Eh7Ik/Fcpx1aRUcK5vwR95oYOwGdnkD7huW1N6RBmofQwWxP XGdG4RiIsaCWkO8oCWFTYYRVN9i7jOLadQURL3xW2IiMMBhhiMhOFDwfROu6bk/ciIV/ b08Q== X-Gm-Message-State: ABUngveyFmk+eOi8v2UaWhun5ygKos7gmOQQiTHE4aB4QqPRPNh/pYTXeVpPZn1+RyizVQ== X-Received: by 10.99.50.67 with SMTP id y64mr9801613pgy.146.1478132458165; Wed, 02 Nov 2016 17:20:58 -0700 (PDT) Received: from linux-rxt1.site ([124.11.22.254]) by smtp.gmail.com with ESMTPSA id xn11sm7369545pac.38.2016.11.02.17.20.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Nov 2016 17:20:57 -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 v2] acer-wmi: setup accelerometer when machine has appropriate notify event Date: Thu, 3 Nov 2016 08:18:52 +0800 Message-Id: <1478132332-25284-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. v2: Fix the string comparison logic of SENR. Reported-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(-) -- To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux/drivers/platform/x86/acer-wmi.c =================================================================== --- linux.orig/drivers/platform/x86/acer-wmi.c +++ linux/drivers/platform/x86/acer-wmi.c @@ -1808,11 +1808,24 @@ static int __init acer_wmi_enable_lm(voi 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(v { 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");