]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.32.12/thinkpad-acpi-sync-input-device-ev_sw-initial-state.patch
Fixes for 5.10
[thirdparty/kernel/stable-queue.git] / releases / 2.6.32.12 / thinkpad-acpi-sync-input-device-ev_sw-initial-state.patch
1 From d89a727aff649f6768f7a34ee57f031ebf8bab4c Mon Sep 17 00:00:00 2001
2 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
3 Date: Tue, 15 Dec 2009 21:51:06 -0200
4 Subject: thinkpad-acpi: sync input device EV_SW initial state
5
6 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
7
8 commit d89a727aff649f6768f7a34ee57f031ebf8bab4c upstream.
9
10 Before we register the input device, sync the input layer EV_SW state
11 through a call to input_report_switch(), to avoid issuing a gratuitous
12 event for the initial state of these switches.
13
14 This fixes some annoyances caused by the interaction with rfkill and
15 EV_SW SW_RFKILL_ALL events.
16
17 Reported-by: Kevin Locke <kevin@kevinlocke.name>
18 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
19 Cc: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
20 Cc: Johannes Berg <johannes@sipsolutions.net>
21 Cc: Dmitry Torokhov <dtor@mail.ru>
22 Signed-off-by: Len Brown <len.brown@intel.com>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
24
25 ---
26 drivers/platform/x86/thinkpad_acpi.c | 14 ++++++++++----
27 1 file changed, 10 insertions(+), 4 deletions(-)
28
29 --- a/drivers/platform/x86/thinkpad_acpi.c
30 +++ b/drivers/platform/x86/thinkpad_acpi.c
31 @@ -3188,6 +3188,8 @@ static int __init hotkey_init(struct ibm
32 int res, i;
33 int status;
34 int hkeyv;
35 + bool radiosw_state = false;
36 + bool tabletsw_state = false;
37
38 unsigned long quirks;
39
40 @@ -3293,6 +3295,7 @@ static int __init hotkey_init(struct ibm
41 #ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
42 if (dbg_wlswemul) {
43 tp_features.hotkey_wlsw = 1;
44 + radiosw_state = !!tpacpi_wlsw_emulstate;
45 printk(TPACPI_INFO
46 "radio switch emulation enabled\n");
47 } else
48 @@ -3300,6 +3303,7 @@ static int __init hotkey_init(struct ibm
49 /* Not all thinkpads have a hardware radio switch */
50 if (acpi_evalf(hkey_handle, &status, "WLSW", "qd")) {
51 tp_features.hotkey_wlsw = 1;
52 + radiosw_state = !!status;
53 printk(TPACPI_INFO
54 "radio switch found; radios are %s\n",
55 enabled(status, 0));
56 @@ -3311,11 +3315,11 @@ static int __init hotkey_init(struct ibm
57 /* For X41t, X60t, X61t Tablets... */
58 if (!res && acpi_evalf(hkey_handle, &status, "MHKG", "qd")) {
59 tp_features.hotkey_tablet = 1;
60 + tabletsw_state = !!(status & TP_HOTKEY_TABLET_MASK);
61 printk(TPACPI_INFO
62 "possible tablet mode switch found; "
63 "ThinkPad in %s mode\n",
64 - (status & TP_HOTKEY_TABLET_MASK)?
65 - "tablet" : "laptop");
66 + (tabletsw_state) ? "tablet" : "laptop");
67 res = add_to_attr_set(hotkey_dev_attributes,
68 &dev_attr_hotkey_tablet_mode.attr);
69 }
70 @@ -3366,9 +3370,13 @@ static int __init hotkey_init(struct ibm
71
72 if (tp_features.hotkey_wlsw) {
73 input_set_capability(tpacpi_inputdev, EV_SW, SW_RFKILL_ALL);
74 + input_report_switch(tpacpi_inputdev,
75 + SW_RFKILL_ALL, radiosw_state);
76 }
77 if (tp_features.hotkey_tablet) {
78 input_set_capability(tpacpi_inputdev, EV_SW, SW_TABLET_MODE);
79 + input_report_switch(tpacpi_inputdev,
80 + SW_TABLET_MODE, tabletsw_state);
81 }
82
83 /* Do not issue duplicate brightness change events to
84 @@ -3435,8 +3443,6 @@ static int __init hotkey_init(struct ibm
85 tpacpi_inputdev->close = &hotkey_inputdev_close;
86
87 hotkey_poll_setup_safe(true);
88 - tpacpi_send_radiosw_update();
89 - tpacpi_input_send_tabletsw();
90
91 return 0;
92