From patchwork Tue Nov 1 04:33:32 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: 9406895 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 C2ED460234 for ; Tue, 1 Nov 2016 04:35:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3BB22949E for ; Tue, 1 Nov 2016 04:35:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7E3D294A5; Tue, 1 Nov 2016 04:35:40 +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 22FF02949E for ; Tue, 1 Nov 2016 04:35:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965633AbcKAEfj (ORCPT ); Tue, 1 Nov 2016 00:35:39 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36788 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932631AbcKAEfi (ORCPT ); Tue, 1 Nov 2016 00:35:38 -0400 Received: by mail-pf0-f193.google.com with SMTP id n85so10521805pfi.3; Mon, 31 Oct 2016 21:35:38 -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=lO/hOwGOHRj0Wgk5ruFMx7ZG/DCTD45DTVcZGE2ttPM0e0bi4JiB9VYcrZShrHzIEv xGaT5YgLqGXp+Bx3qV1LOPqgb5keENdBTpS9DvvXVowRc5aZQB5CwyYRirAkzb55mO3P Ol/+YWsUXhWq1Ettm8TjxXuLjOzB1CtZgCFKz6VxZQGsOESocHE/BFYYUQENOlGQnAxp 6tWwvFc6Q4Ck0LZL/LOMd0F9AyzkjNdJUZ4djQZZDHSwjs7/0pCaoaFvWxXxZRE3VvxM GAJ/rkLZBS2ftEGcV7k6TLMP0T4MtYrf2oZfDp4kP24DOfWw4V9g6J9ahV9nzMNM31qS vAmg== 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=CkbtKGct63dYp9+r6yn5R19oiqf0Ouc7q8XucA1g9oq3ICawMRExNfVIHACMWbZD2+ GBoIdpCytQeoFpgUzvfI0GEQdwP8xx4JEEYXZfzRXMJkgZmw4HfAr//tRwf52HclKSv/ fGQI8AyTGgf1FOsM7RQGtZ7ymAyPZ+/mwHvJoYXvWC8hdqqQ3uorvdvXWl34CyJG1TO4 SkDY/RI6DVcO22k8bR0xFy9EmTEM3/U0kMagiWWNN+FL2oha23dD3FDCVQitxnyVXMzQ dDojlYHrCiaN72hJhp/zOOEfwaJY62dAS/xRWSB36qribAW4ICx4xwtNgSP5w7VXD3ET u/vg== X-Gm-Message-State: ABUngvdLckk9wGC2gZiRMlIw2r60UPz02jCWldRDo51fo2TiPYBXxtMdheGidYl/M2kfnA== X-Received: by 10.98.8.29 with SMTP id c29mr38112037pfd.67.1477974938048; Mon, 31 Oct 2016 21:35:38 -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 v10sm38870451pag.44.2016.10.31.21.35.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Oct 2016 21:35:37 -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: Tue, 1 Nov 2016 12:33:32 +0800 Message-Id: <1477974812-12657-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");