From patchwork Mon Aug 29 10:00:21 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: 9303385 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 AECA1601C0 for ; Mon, 29 Aug 2016 10:02:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F4DD28693 for ; Mon, 29 Aug 2016 10:02:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93F422874C; Mon, 29 Aug 2016 10:02:33 +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 BE92428739 for ; Mon, 29 Aug 2016 10:02:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756681AbcH2KCa (ORCPT ); Mon, 29 Aug 2016 06:02:30 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:34333 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756125AbcH2KC3 (ORCPT ); Mon, 29 Aug 2016 06:02:29 -0400 Received: by mail-pf0-f196.google.com with SMTP id g202so9073939pfb.1; Mon, 29 Aug 2016 03:02: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=WC2+8AFwxu4KKiIy/tk0qdm91h0VR3rzXeAzlpb2/9E=; b=X/4epSlrYbiPDax5qowtkmdfD+A+8A4sWsizqhAQ7G8hfOWb9B21IkslYuVxHNvwKz jvuwkSZ7q8DB3JTKhQyCthQcsWq46P1uO4zFzX3B+G8uTtaekqIBd/ms0tW3ZuR2Ca49 gcEjiPHBgQk0DNjK7qjepShnn6sakxAJw76RqT5h037syBB1DtmvASFIfHbxQo2zPmSd YxJdCP4a9e7ylZ6lL4uoH105jSD2qo6gv4oApWbJcBoOkf92+IMdes2/dB6dgjycVrTW 8jY8uncfTpmvwnAHfTWnmB2HIaN+L5pa3J800507dXFc/08VAOvwE5dfl2877sGoNE51 hJ/Q== 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=WC2+8AFwxu4KKiIy/tk0qdm91h0VR3rzXeAzlpb2/9E=; b=MCZ0lCsUUjQ0K8Ro6ao+27fZqKtOuvOb15uamcqfmL3m4UmLDO8hmO/JlOQ2Ug4zqw 7GQQG5Io8apuEIuC6Mt3yiCtQp7I84Xp90HkadsttTgpG6J4aom2ijgshnBWcNwWU3N1 9KhxSys58UPi1ThYzbefTYGIH0A3IT8n1nrMjVawJx1dC4OCKKjAur4d0l9i18cu8JEh Q9yUUsACdcJjtuCZJbRiOG3/XP0QIyncUz1+q/hyXYyWiKox75OI+Gc1YBpiza6jvA79 nIp1wDcNMnMd/IQYioV8vc+spRuSmd1rSLDX9Shp4hDYH0uHv+UUwAlVa21dElSN+P2W mR9Q== X-Gm-Message-State: AE9vXwMjG88YDPgD39GHQVJPQNQ8FW4HNMvfFSAoj1yauZE39ZeMzJwPenoBTs07ygw2rQ== X-Received: by 10.98.63.1 with SMTP id m1mr31073064pfa.14.1472464948481; Mon, 29 Aug 2016 03:02:28 -0700 (PDT) Received: from linux-rxt1.site (59-124-67-67.HINET-IP.hinet.net. [59.124.67.67]) by smtp.gmail.com with ESMTPSA id v26sm47883822pfi.41.2016.08.29.03.02.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Aug 2016 03:02:27 -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: Mon, 29 Aug 2016 18:00:21 +0800 Message-Id: <1472464821-10360-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 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");