Add patches accepted for 2.6.30-rc1
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / releases / upstream / 2.6.30-rc1 / 0009-thinkpad-acpi-remove-HKEY-disable-functionality.patch
blob27ecd400c958dce813891ca92be09abfaf2ed23e
1 From 2586d5663d0a17d69383acf6110f16a979a07c4e Mon Sep 17 00:00:00 2001
2 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
3 Date: Sat, 4 Apr 2009 04:25:48 +0000
4 Subject: thinkpad-acpi: remove HKEY disable functionality
6 The HKEY disable functionality basically cripples the entire event
7 model of the ThinkPad firmware and of the thinkpad-acpi driver.
8 Remove this functionality from the driver. HKEY must be enabled at
9 all times while thinkpad-acpi is loaded, and disabled otherwise.
11 For sysfs, according to the sysfs ABI and the thinkpad-acpi sysfs
12 rules of engagement, we will just remove the attributes. This will be
13 done in two stages: disable their function now, after two kernel
14 releases, remove the attributes.
16 For procfs, we call WARN(). If nothing triggers it, I will simply
17 remove the enable/disable commands entirely in the future along with
18 the sysfs attributes.
20 I don't expect much, if any fallout from this. There really isn't any
21 reason to mess with hotkey_enable or with the enable/disable commands
22 to /proc/acpi/ibm/hotkey, and this has been true for years...
24 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
25 Signed-off-by: Len Brown <len.brown@intel.com>
26 ---
27 Documentation/laptops/thinkpad-acpi.txt | 39 ++++++++++++------------
28 drivers/platform/x86/thinkpad_acpi.c | 49 +++++++++++++++++--------------
29 2 files changed, 46 insertions(+), 42 deletions(-)
31 diff --git a/Documentation/laptops/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt
32 index e8f52fb..de6f14c 100644
33 --- a/Documentation/laptops/thinkpad-acpi.txt
34 +++ b/Documentation/laptops/thinkpad-acpi.txt
35 @@ -179,17 +179,14 @@ system. Enabling the hotkey functionality of thinkpad-acpi signals the
36 firmware that such a driver is present, and modifies how the ThinkPad
37 firmware will behave in many situations.
39 -The driver enables the hot key feature automatically when loaded. The
40 -feature can later be disabled and enabled back at runtime. The driver
41 -will also restore the hot key feature to its previous state and mask
42 -when it is unloaded.
43 +The driver enables the HKEY ("hot key") event reporting automatically
44 +when loaded, and disables it when it is removed.
46 -When the hotkey feature is enabled and the hot key mask is set (see
47 -below), the driver will report HKEY events in the following format:
48 +The driver will report HKEY events in the following format:
50 ibm/hotkey HKEY 00000080 0000xxxx
52 -Some of these events refer to hot key presses, but not all.
53 +Some of these events refer to hot key presses, but not all of them.
55 The driver will generate events over the input layer for hot keys and
56 radio switches, and over the ACPI netlink layer for other events. The
57 @@ -221,13 +218,17 @@ procfs notes:
59 The following commands can be written to the /proc/acpi/ibm/hotkey file:
61 - echo enable > /proc/acpi/ibm/hotkey -- enable the hot keys feature
62 - echo disable > /proc/acpi/ibm/hotkey -- disable the hot keys feature
63 echo 0xffffffff > /proc/acpi/ibm/hotkey -- enable all hot keys
64 echo 0 > /proc/acpi/ibm/hotkey -- disable all possible hot keys
65 ... any other 8-hex-digit mask ...
66 echo reset > /proc/acpi/ibm/hotkey -- restore the original mask
68 +The following commands have been deprecated and will cause the kernel
69 +to log a warning:
71 + echo enable > /proc/acpi/ibm/hotkey -- does nothing
72 + echo disable > /proc/acpi/ibm/hotkey -- returns an error
74 The procfs interface does not support NVRAM polling control. So as to
75 maintain maximum bug-to-bug compatibility, it does not report any masks,
76 nor does it allow one to manipulate the hot key mask when the firmware
77 @@ -236,12 +237,9 @@ does not support masks at all, even if NVRAM polling is in use.
78 sysfs notes:
80 hotkey_bios_enabled:
81 - Returns the status of the hot keys feature when
82 - thinkpad-acpi was loaded. Upon module unload, the hot
83 - key feature status will be restored to this value.
84 + DEPRECATED, WILL BE REMOVED SOON.
86 - 0: hot keys were disabled
87 - 1: hot keys were enabled (unusual)
88 + Returns 0.
90 hotkey_bios_mask:
91 Returns the hot keys mask when thinkpad-acpi was loaded.
92 @@ -249,13 +247,10 @@ sysfs notes:
93 to this value.
95 hotkey_enable:
96 - Enables/disables the hot keys feature in the ACPI
97 - firmware, and reports current status of the hot keys
98 - feature. Has no effect on the NVRAM hot key polling
99 - functionality.
100 + DEPRECATED, WILL BE REMOVED SOON.
102 - 0: disables the hot keys feature / feature disabled
103 - 1: enables the hot keys feature / feature enabled
104 + 0: returns -EPERM
105 + 1: does nothing
107 hotkey_mask:
108 bit mask to enable driver-handling (and depending on
109 @@ -1535,3 +1530,7 @@ Sysfs interface changelog:
111 0x020200: Add poll()/select() support to the following attributes:
112 hotkey_radio_sw, wakeup_hotunplug_complete, wakeup_reason
114 +0x020300: hotkey enable/disable support removed, attributes
115 + hotkey_bios_enabled and hotkey_enable deprecated and
116 + marked for removal.
117 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
118 index 852be7c..f003fb7 100644
119 --- a/drivers/platform/x86/thinkpad_acpi.c
120 +++ b/drivers/platform/x86/thinkpad_acpi.c
121 @@ -22,7 +22,7 @@
124 #define TPACPI_VERSION "0.22"
125 -#define TPACPI_SYSFS_VERSION 0x020200
126 +#define TPACPI_SYSFS_VERSION 0x020300
129 * Changelog:
130 @@ -1424,7 +1424,6 @@ static enum { /* Reasons for waking up */
132 static int hotkey_autosleep_ack;
134 -static int hotkey_orig_status;
135 static u32 hotkey_orig_mask;
136 static u32 hotkey_all_mask;
137 static u32 hotkey_reserved_mask;
138 @@ -1571,9 +1570,9 @@ static int hotkey_status_get(int *status)
139 return 0;
142 -static int hotkey_status_set(int status)
143 +static int hotkey_status_set(bool enable)
145 - if (!acpi_evalf(hkey_handle, NULL, "MHKC", "vd", status))
146 + if (!acpi_evalf(hkey_handle, NULL, "MHKC", "vd", enable ? 1 : 0))
147 return -EIO;
149 return 0;
150 @@ -1889,6 +1888,9 @@ static ssize_t hotkey_enable_show(struct device *dev,
152 int res, status;
154 + printk_deprecated_attribute("hotkey_enable",
155 + "Hotkey reporting is always enabled");
157 res = hotkey_status_get(&status);
158 if (res)
159 return res;
160 @@ -1901,14 +1903,17 @@ static ssize_t hotkey_enable_store(struct device *dev,
161 const char *buf, size_t count)
163 unsigned long t;
164 - int res;
166 + printk_deprecated_attribute("hotkey_enable",
167 + "Hotkeys can be disabled through hotkey_mask");
169 if (parse_strtoul(buf, 1, &t))
170 return -EINVAL;
172 - res = hotkey_status_set(t);
173 + if (t == 0)
174 + return -EPERM;
176 - return (res) ? res : count;
177 + return count;
180 static struct device_attribute dev_attr_hotkey_enable =
181 @@ -1964,7 +1969,7 @@ static ssize_t hotkey_bios_enabled_show(struct device *dev,
182 struct device_attribute *attr,
183 char *buf)
185 - return snprintf(buf, PAGE_SIZE, "%d\n", hotkey_orig_status);
186 + return sprintf(buf, "0\n");
189 static struct device_attribute dev_attr_hotkey_bios_enabled =
190 @@ -2243,7 +2248,7 @@ static void hotkey_exit(void)
191 "restoring original hot key mask\n");
192 /* no short-circuit boolean operator below! */
193 if ((hotkey_mask_set(hotkey_orig_mask) |
194 - hotkey_status_set(hotkey_orig_status)) != 0)
195 + hotkey_status_set(false)) != 0)
196 printk(TPACPI_ERR
197 "failed to restore hot key mask "
198 "to BIOS defaults\n");
199 @@ -2438,10 +2443,6 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
201 /* hotkey_source_mask *must* be zero for
202 * the first hotkey_mask_get */
203 - res = hotkey_status_get(&hotkey_orig_status);
204 - if (res)
205 - goto err_exit;
207 if (tp_features.hotkey_mask) {
208 res = hotkey_mask_get();
209 if (res)
210 @@ -2581,7 +2582,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
213 dbg_printk(TPACPI_DBG_INIT, "enabling hot key handling\n");
214 - res = hotkey_status_set(1);
215 + res = hotkey_status_set(true);
216 if (res) {
217 hotkey_exit();
218 return res;
219 @@ -2926,9 +2927,17 @@ static int hotkey_read(char *p)
220 return len;
223 +static void hotkey_enabledisable_warn(void)
225 + tpacpi_log_usertask("procfs hotkey enable/disable");
226 + WARN(1, TPACPI_WARN
227 + "hotkey enable/disable functionality has been "
228 + "removed from the driver. Hotkeys are always enabled.\n");
231 static int hotkey_write(char *buf)
233 - int res, status;
234 + int res;
235 u32 mask;
236 char *cmd;
238 @@ -2938,17 +2947,16 @@ static int hotkey_write(char *buf)
239 if (mutex_lock_killable(&hotkey_mutex))
240 return -ERESTARTSYS;
242 - status = -1;
243 mask = hotkey_mask;
245 res = 0;
246 while ((cmd = next_cmd(&buf))) {
247 if (strlencmp(cmd, "enable") == 0) {
248 - status = 1;
249 + hotkey_enabledisable_warn();
250 } else if (strlencmp(cmd, "disable") == 0) {
251 - status = 0;
252 + hotkey_enabledisable_warn();
253 + res = -EPERM;
254 } else if (strlencmp(cmd, "reset") == 0) {
255 - status = hotkey_orig_status;
256 mask = hotkey_orig_mask;
257 } else if (sscanf(cmd, "0x%x", &mask) == 1) {
258 /* mask set */
259 @@ -2959,9 +2967,6 @@ static int hotkey_write(char *buf)
260 goto errexit;
263 - if (status != -1)
264 - res = hotkey_status_set(status);
266 if (!res && mask != hotkey_mask)
267 res = hotkey_mask_set(mask);
270 1.6.2.1