1 From 98d610c3739ac354319a6590b915f4624d9151e6 Mon Sep 17 00:00:00 2001
2 From: "Lee, Chun-Yi" <joeyli.kernel@gmail.com>
3 Date: Thu, 3 Nov 2016 08:18:52 +0800
4 Subject: platform/x86: acer-wmi: setup accelerometer when machine has appropriate notify event
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 From: Lee, Chun-Yi <joeyli.kernel@gmail.com>
11 commit 98d610c3739ac354319a6590b915f4624d9151e6 upstream.
13 The accelerometer event relies on the ACERWMID_EVENT_GUID notify.
14 So, this patch changes the codes to setup accelerometer input device
15 when detected ACERWMID_EVENT_GUID. It avoids that the accel input
16 device created on every Acer machines.
18 In addition, patch adds a clearly parsing logic of accelerometer hid
19 to acer_wmi_get_handle_cb callback function. It is positive matching
20 the "SENR" name with "BST0001" device to avoid non-supported hardware.
22 Reported-by: Bjørn Mork <bjorn@mork.no>
23 Cc: Darren Hart <dvhart@infradead.org>
24 Signed-off-by: Lee, Chun-Yi <jlee@suse.com>
25 [andy: slightly massage commit message]
26 Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
27 Cc: Ben Hutchings <ben@decadent.org.uk>
28 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
31 drivers/platform/x86/acer-wmi.c | 22 ++++++++++++++++++----
32 1 file changed, 18 insertions(+), 4 deletions(-)
34 --- a/drivers/platform/x86/acer-wmi.c
35 +++ b/drivers/platform/x86/acer-wmi.c
36 @@ -1846,11 +1846,24 @@ static int __init acer_wmi_enable_lm(voi
40 +#define ACER_WMID_ACCEL_HID "BST0001"
42 static acpi_status __init acer_wmi_get_handle_cb(acpi_handle ah, u32 level,
43 void *ctx, void **retval)
45 + struct acpi_device *dev;
47 + if (!strcmp(ctx, "SENR")) {
48 + if (acpi_bus_get_device(ah, &dev))
50 + if (!strcmp(ACER_WMID_ACCEL_HID, acpi_device_hid(dev)))
55 *(acpi_handle *)retval = ah;
58 + return AE_CTRL_TERMINATE;
61 static int __init acer_wmi_get_handle(const char *name, const char *prop,
62 @@ -1877,7 +1890,7 @@ static int __init acer_wmi_accel_setup(v
66 - err = acer_wmi_get_handle("SENR", "BST0001", &gsensor_handle);
67 + err = acer_wmi_get_handle("SENR", ACER_WMID_ACCEL_HID, &gsensor_handle);
71 @@ -2233,10 +2246,11 @@ static int __init acer_wmi_init(void)
72 err = acer_wmi_input_setup();
75 + err = acer_wmi_accel_setup();
80 - acer_wmi_accel_setup();
82 err = platform_driver_register(&acer_platform_driver);
84 pr_err("Unable to register platform driver\n");