hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/platform/x86/acer-wmi.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Acer WMI Laptop Extras
34 *
....@@ -6,20 +7,6 @@
67 * Based on acer_acpi:
78 * Copyright (C) 2005-2007 E.M. Smith
89 * Copyright (C) 2007-2008 Carlos Corbacho <cathectic@gmail.com>
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version.
14
- *
15
- * This program is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
- * GNU General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU General Public License
21
- * along with this program; if not, write to the Free Software
22
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2310 */
2411
2512 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -106,6 +93,7 @@
10693 {KE_KEY, 0x22, {KEY_PROG2} }, /* Arcade */
10794 {KE_KEY, 0x23, {KEY_PROG3} }, /* P_Key */
10895 {KE_KEY, 0x24, {KEY_PROG4} }, /* Social networking_Key */
96
+ {KE_KEY, 0x27, {KEY_HELP} },
10997 {KE_KEY, 0x29, {KEY_PROG3} }, /* P_Key for TM8372 */
11098 {KE_IGNORE, 0x41, {KEY_MUTE} },
11199 {KE_IGNORE, 0x42, {KEY_PREVIOUSSONG} },
....@@ -119,7 +107,13 @@
119107 {KE_IGNORE, 0x48, {KEY_VOLUMEUP} },
120108 {KE_IGNORE, 0x49, {KEY_VOLUMEDOWN} },
121109 {KE_IGNORE, 0x4a, {KEY_VOLUMEDOWN} },
122
- {KE_IGNORE, 0x61, {KEY_SWITCHVIDEOMODE} },
110
+ /*
111
+ * 0x61 is KEY_SWITCHVIDEOMODE. Usually this is a duplicate input event
112
+ * with the "Video Bus" input device events. But sometimes it is not
113
+ * a dup. Map it to KEY_UNKNOWN instead of using KE_IGNORE so that
114
+ * udev/hwdb can override it on systems where it is not a dup.
115
+ */
116
+ {KE_KEY, 0x61, {KEY_UNKNOWN} },
123117 {KE_IGNORE, 0x62, {KEY_BRIGHTNESSUP} },
124118 {KE_IGNORE, 0x63, {KEY_BRIGHTNESSDOWN} },
125119 {KE_KEY, 0x64, {KEY_SWITCHVIDEOMODE} }, /* Display Switch */
....@@ -278,7 +272,6 @@
278272
279273 struct acer_debug {
280274 struct dentry *root;
281
- struct dentry *devices;
282275 u32 wmid_devices;
283276 };
284277
....@@ -540,6 +533,15 @@
540533 .matches = {
541534 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
542535 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW5-012"),
536
+ },
537
+ .driver_data = (void *)ACER_CAP_KBD_DOCK,
538
+ },
539
+ {
540
+ .callback = set_force_caps,
541
+ .ident = "Acer Aspire Switch V 10 SW5-017",
542
+ .matches = {
543
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Acer"),
544
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "SW5-017"),
543545 },
544546 .driver_data = (void *)ACER_CAP_KBD_DOCK,
545547 },
....@@ -1057,6 +1059,7 @@
10571059 *value = tmp & 0x1;
10581060 return 0;
10591061 }
1062
+ fallthrough;
10601063 default:
10611064 return AE_ERROR;
10621065 }
....@@ -1381,6 +1384,7 @@
13811384 status = AMW0_get_u32(value, cap);
13821385 break;
13831386 }
1387
+ fallthrough;
13841388 case ACER_WMID:
13851389 status = WMID_get_u32(value, cap);
13861390 break;
....@@ -1423,6 +1427,7 @@
14231427
14241428 return AMW0_set_u32(value, cap);
14251429 }
1430
+ fallthrough;
14261431 case ACER_WMID:
14271432 return WMID_set_u32(value, cap);
14281433 case ACER_WMID_v2:
....@@ -1432,6 +1437,7 @@
14321437 return wmid_v2_set_u32(value, cap);
14331438 else if (wmi_has_guid(WMID_GUID2))
14341439 return WMID_set_u32(value, cap);
1440
+ fallthrough;
14351441 default:
14361442 return AE_BAD_PARAMETER;
14371443 }
....@@ -1997,52 +2003,17 @@
19972003 return status;
19982004 }
19992005
2000
-#define ACER_WMID_ACCEL_HID "BST0001"
2001
-
2002
-static acpi_status __init acer_wmi_get_handle_cb(acpi_handle ah, u32 level,
2003
- void *ctx, void **retval)
2004
-{
2005
- struct acpi_device *dev;
2006
-
2007
- if (!strcmp(ctx, "SENR")) {
2008
- if (acpi_bus_get_device(ah, &dev))
2009
- return AE_OK;
2010
- if (strcmp(ACER_WMID_ACCEL_HID, acpi_device_hid(dev)))
2011
- return AE_OK;
2012
- } else
2013
- return AE_OK;
2014
-
2015
- *(acpi_handle *)retval = ah;
2016
-
2017
- return AE_CTRL_TERMINATE;
2018
-}
2019
-
2020
-static int __init acer_wmi_get_handle(const char *name, const char *prop,
2021
- acpi_handle *ah)
2022
-{
2023
- acpi_status status;
2024
- acpi_handle handle;
2025
-
2026
- BUG_ON(!name || !ah);
2027
-
2028
- handle = NULL;
2029
- status = acpi_get_devices(prop, acer_wmi_get_handle_cb,
2030
- (void *)name, &handle);
2031
- if (ACPI_SUCCESS(status) && handle) {
2032
- *ah = handle;
2033
- return 0;
2034
- } else {
2035
- return -ENODEV;
2036
- }
2037
-}
2038
-
20392006 static int __init acer_wmi_accel_setup(void)
20402007 {
2008
+ struct acpi_device *adev;
20412009 int err;
20422010
2043
- err = acer_wmi_get_handle("SENR", ACER_WMID_ACCEL_HID, &gsensor_handle);
2044
- if (err)
2045
- return err;
2011
+ adev = acpi_dev_get_first_match_dev("BST0001", NULL, -1);
2012
+ if (!adev)
2013
+ return -ENODEV;
2014
+
2015
+ gsensor_handle = acpi_device_handle(adev);
2016
+ acpi_dev_put(adev);
20462017
20472018 acer_wmi_accel_dev = input_allocate_device();
20482019 if (!acer_wmi_accel_dev)
....@@ -2266,29 +2237,15 @@
22662237
22672238 static void remove_debugfs(void)
22682239 {
2269
- debugfs_remove(interface->debug.devices);
2270
- debugfs_remove(interface->debug.root);
2240
+ debugfs_remove_recursive(interface->debug.root);
22712241 }
22722242
2273
-static int __init create_debugfs(void)
2243
+static void __init create_debugfs(void)
22742244 {
22752245 interface->debug.root = debugfs_create_dir("acer-wmi", NULL);
2276
- if (!interface->debug.root) {
2277
- pr_err("Failed to create debugfs directory");
2278
- return -ENOMEM;
2279
- }
22802246
2281
- interface->debug.devices = debugfs_create_u32("devices", S_IRUGO,
2282
- interface->debug.root,
2283
- &interface->debug.wmid_devices);
2284
- if (!interface->debug.devices)
2285
- goto error_debugfs;
2286
-
2287
- return 0;
2288
-
2289
-error_debugfs:
2290
- remove_debugfs();
2291
- return -ENOMEM;
2247
+ debugfs_create_u32("devices", S_IRUGO, interface->debug.root,
2248
+ &interface->debug.wmid_devices);
22922249 }
22932250
22942251 static int __init acer_wmi_init(void)
....@@ -2425,9 +2382,7 @@
24252382
24262383 if (wmi_has_guid(WMID_GUID2)) {
24272384 interface->debug.wmid_devices = get_wmid_devices();
2428
- err = create_debugfs();
2429
- if (err)
2430
- goto error_create_debugfs;
2385
+ create_debugfs();
24312386 }
24322387
24332388 /* Override any initial settings with values from the commandline */
....@@ -2435,8 +2390,6 @@
24352390
24362391 return 0;
24372392
2438
-error_create_debugfs:
2439
- platform_device_del(acer_platform_device);
24402393 error_device_add:
24412394 platform_device_put(acer_platform_device);
24422395 error_device_alloc: