Skip to content

Commit ccf0904

Browse files
Lee, Chun-Yigregkh
authored andcommitted
platform/x86: acer-wmi: setup accelerometer when machine has appropriate notify event
commit 98d610c3739ac354319a6590b915f4624d9151e6 upstream. The accelerometer event relies 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 <bjorn@mork.no> Cc: Darren Hart <dvhart@infradead.org> Signed-off-by: Lee, Chun-Yi <jlee@suse.com> [andy: slightly massage commit message] Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 51f8d95 commit ccf0904

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

drivers/platform/x86/acer-wmi.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,11 +1816,24 @@ static int __init acer_wmi_enable_lm(void)
18161816
return status;
18171817
}
18181818

1819+
#define ACER_WMID_ACCEL_HID "BST0001"
1820+
18191821
static acpi_status __init acer_wmi_get_handle_cb(acpi_handle ah, u32 level,
18201822
void *ctx, void **retval)
18211823
{
1824+
struct acpi_device *dev;
1825+
1826+
if (!strcmp(ctx, "SENR")) {
1827+
if (acpi_bus_get_device(ah, &dev))
1828+
return AE_OK;
1829+
if (!strcmp(ACER_WMID_ACCEL_HID, acpi_device_hid(dev)))
1830+
return AE_OK;
1831+
} else
1832+
return AE_OK;
1833+
18221834
*(acpi_handle *)retval = ah;
1823-
return AE_OK;
1835+
1836+
return AE_CTRL_TERMINATE;
18241837
}
18251838

18261839
static int __init acer_wmi_get_handle(const char *name, const char *prop,
@@ -1847,7 +1860,7 @@ static int __init acer_wmi_accel_setup(void)
18471860
{
18481861
int err;
18491862

1850-
err = acer_wmi_get_handle("SENR", "BST0001", &gsensor_handle);
1863+
err = acer_wmi_get_handle("SENR", ACER_WMID_ACCEL_HID, &gsensor_handle);
18511864
if (err)
18521865
return err;
18531866

@@ -2185,10 +2198,11 @@ static int __init acer_wmi_init(void)
21852198
err = acer_wmi_input_setup();
21862199
if (err)
21872200
return err;
2201+
err = acer_wmi_accel_setup();
2202+
if (err)
2203+
return err;
21882204
}
21892205

2190-
acer_wmi_accel_setup();
2191-
21922206
err = platform_driver_register(&acer_platform_driver);
21932207
if (err) {
21942208
pr_err("Unable to register platform driver\n");

0 commit comments

Comments
 (0)