]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
13cd5a8c616927c101a4da1ea1ae2cc138c34661
[thirdparty/kernel/stable-queue.git] /
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
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 From: Lee, Chun-Yi <joeyli.kernel@gmail.com>
10
11 commit 98d610c3739ac354319a6590b915f4624d9151e6 upstream.
12
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.
17
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.
21
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>
29
30 ---
31 drivers/platform/x86/acer-wmi.c | 22 ++++++++++++++++++----
32 1 file changed, 18 insertions(+), 4 deletions(-)
33
34 --- a/drivers/platform/x86/acer-wmi.c
35 +++ b/drivers/platform/x86/acer-wmi.c
36 @@ -1867,11 +1867,24 @@ static int __init acer_wmi_enable_lm(voi
37 return status;
38 }
39
40 +#define ACER_WMID_ACCEL_HID "BST0001"
41 +
42 static acpi_status __init acer_wmi_get_handle_cb(acpi_handle ah, u32 level,
43 void *ctx, void **retval)
44 {
45 + struct acpi_device *dev;
46 +
47 + if (!strcmp(ctx, "SENR")) {
48 + if (acpi_bus_get_device(ah, &dev))
49 + return AE_OK;
50 + if (!strcmp(ACER_WMID_ACCEL_HID, acpi_device_hid(dev)))
51 + return AE_OK;
52 + } else
53 + return AE_OK;
54 +
55 *(acpi_handle *)retval = ah;
56 - return AE_OK;
57 +
58 + return AE_CTRL_TERMINATE;
59 }
60
61 static int __init acer_wmi_get_handle(const char *name, const char *prop,
62 @@ -1898,7 +1911,7 @@ static int __init acer_wmi_accel_setup(v
63 {
64 int err;
65
66 - err = acer_wmi_get_handle("SENR", "BST0001", &gsensor_handle);
67 + err = acer_wmi_get_handle("SENR", ACER_WMID_ACCEL_HID, &gsensor_handle);
68 if (err)
69 return err;
70
71 @@ -2274,10 +2287,11 @@ static int __init acer_wmi_init(void)
72 err = acer_wmi_input_setup();
73 if (err)
74 return err;
75 + err = acer_wmi_accel_setup();
76 + if (err)
77 + return err;
78 }
79
80 - acer_wmi_accel_setup();
81 -
82 err = platform_driver_register(&acer_platform_driver);
83 if (err) {
84 pr_err("Unable to register platform driver\n");