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 / 0011-thinkpad-acpi-enhanced-debugging-messages-for-rfkil.patch
blob140a164eaeb505fd8892d0f054ed288f7e04b2c3
1 From bee4cd9b9eaa8c72832e1ee7f4940604e94beb27 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:50 +0000
4 Subject: thinkpad-acpi: enhanced debugging messages for rfkill subdrivers
6 Enhance debugging messages for all rfkill subdrivers in thinkpad-acpi.
8 Also, log a warning if the deprecated sysfs attributes are in use.
9 These attributes are going to be removed sometime in 2010.
11 There is an user-visible side-effect: we now coalesce attempts to
12 enable/disable bluetooth or WWAN in the procfs interface, instead of
13 hammering the firmware with multiple requests.
15 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
16 Signed-off-by: Len Brown <len.brown@intel.com>
17 ---
18 Documentation/laptops/thinkpad-acpi.txt | 2 +
19 drivers/platform/x86/thinkpad_acpi.c | 117 +++++++++++++++++++++++++------
20 2 files changed, 98 insertions(+), 21 deletions(-)
22 diff --git a/Documentation/laptops/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt
23 index bce1d95..7daca05 100644
24 --- a/Documentation/laptops/thinkpad-acpi.txt
25 +++ b/Documentation/laptops/thinkpad-acpi.txt
26 @@ -1494,6 +1494,8 @@ to enable more than one output class, just add their values.
27 accessing some functions of the driver
28 0x0001 Initialization and probing
29 0x0002 Removal
30 + 0x0004 RF Transmitter control (RFKILL)
31 + (bluetooth, WWAN, UWB...)
33 There is also a kernel build option to enable more debugging
34 information, which may be necessary to debug driver problems.
35 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
36 index 38c34c7..57ab551 100644
37 --- a/drivers/platform/x86/thinkpad_acpi.c
38 +++ b/drivers/platform/x86/thinkpad_acpi.c
39 @@ -189,6 +189,7 @@ enum {
40 #define TPACPI_DBG_DISCLOSETASK 0x8000
41 #define TPACPI_DBG_INIT 0x0001
42 #define TPACPI_DBG_EXIT 0x0002
43 +#define TPACPI_DBG_RFKILL 0x0004
45 #define onoff(status, bit) ((status) & (1 << (bit)) ? "on" : "off")
46 #define enabled(status, bit) ((status) & (1 << (bit)) ? "enabled" : "disabled")
47 @@ -1016,10 +1017,13 @@ static int __init tpacpi_new_rfkill(const unsigned int id,
48 /* try to set the initial state as the default for the rfkill
49 * type, since we ask the firmware to preserve it across S5 in
50 * NVRAM */
51 - rfkill_set_default(rfktype,
52 + if (rfkill_set_default(rfktype,
53 (initial_state == RFKILL_STATE_UNBLOCKED) ?
54 RFKILL_STATE_UNBLOCKED :
55 - RFKILL_STATE_SOFT_BLOCKED);
56 + RFKILL_STATE_SOFT_BLOCKED) == -EPERM)
57 + vdbg_printk(TPACPI_DBG_RFKILL,
58 + "Default state for %s cannot be changed\n",
59 + name);
62 *rfk = rfkill_allocate(&tpacpi_pdev->dev, rfktype);
63 @@ -3018,13 +3022,17 @@ enum {
64 TP_ACPI_BLTH_SAVE_STATE = 0x05, /* Save state for S4/S5 */
67 +#define TPACPI_RFK_BLUETOOTH_SW_NAME "tpacpi_bluetooth_sw"
69 static struct rfkill *tpacpi_bluetooth_rfkill;
71 static void bluetooth_suspend(pm_message_t state)
73 /* Try to make sure radio will resume powered off */
74 - acpi_evalf(NULL, NULL, "\\BLTH", "vd",
75 - TP_ACPI_BLTH_PWR_OFF_ON_RESUME);
76 + if (!acpi_evalf(NULL, NULL, "\\BLTH", "vd",
77 + TP_ACPI_BLTH_PWR_OFF_ON_RESUME))
78 + vdbg_printk(TPACPI_DBG_RFKILL,
79 + "bluetooth power down on resume request failed\n");
82 static int bluetooth_get_radiosw(void)
83 @@ -3062,6 +3070,10 @@ static void bluetooth_update_rfk(void)
84 if (status < 0)
85 return;
86 rfkill_force_state(tpacpi_bluetooth_rfkill, status);
88 + vdbg_printk(TPACPI_DBG_RFKILL,
89 + "forced rfkill state to %d\n",
90 + status);
93 static int bluetooth_set_radiosw(int radio_on, int update_rfk)
94 @@ -3077,6 +3089,9 @@ static int bluetooth_set_radiosw(int radio_on, int update_rfk)
95 && radio_on)
96 return -EPERM;
98 + vdbg_printk(TPACPI_DBG_RFKILL,
99 + "will %s bluetooth\n", radio_on ? "enable" : "disable");
101 #ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
102 if (dbg_bluetoothemul) {
103 tpacpi_bluetooth_emulstate = !!radio_on;
104 @@ -3129,6 +3144,8 @@ static ssize_t bluetooth_enable_store(struct device *dev,
105 if (parse_strtoul(buf, 1, &t))
106 return -EINVAL;
108 + tpacpi_disclose_usertask("bluetooth_enable", "set to %ld\n", t);
110 res = bluetooth_set_radiosw(t, 1);
112 return (res) ? res : count;
113 @@ -3162,6 +3179,8 @@ static int tpacpi_bluetooth_rfk_get(void *data, enum rfkill_state *state)
115 static int tpacpi_bluetooth_rfk_set(void *data, enum rfkill_state state)
117 + dbg_printk(TPACPI_DBG_RFKILL,
118 + "request to change radio state to %d\n", state);
119 return bluetooth_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0);
122 @@ -3172,6 +3191,9 @@ static void bluetooth_shutdown(void)
123 TP_ACPI_BLTH_SAVE_STATE))
124 printk(TPACPI_NOTICE
125 "failed to save bluetooth state to NVRAM\n");
126 + else
127 + vdbg_printk(TPACPI_DBG_RFKILL,
128 + "bluestooth state saved to NVRAM\n");
131 static void bluetooth_exit(void)
132 @@ -3190,7 +3212,8 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
133 int res;
134 int status = 0;
136 - vdbg_printk(TPACPI_DBG_INIT, "initializing bluetooth subdriver\n");
137 + vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL,
138 + "initializing bluetooth subdriver\n");
140 TPACPI_ACPIHANDLE_INIT(hkey);
142 @@ -3199,7 +3222,8 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
143 tp_features.bluetooth = hkey_handle &&
144 acpi_evalf(hkey_handle, &status, "GBDC", "qd");
146 - vdbg_printk(TPACPI_DBG_INIT, "bluetooth is %s, status 0x%02x\n",
147 + vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL,
148 + "bluetooth is %s, status 0x%02x\n",
149 str_supported(tp_features.bluetooth),
150 status);
152 @@ -3214,7 +3238,7 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
153 !(status & TP_ACPI_BLUETOOTH_HWPRESENT)) {
154 /* no bluetooth hardware present in system */
155 tp_features.bluetooth = 0;
156 - dbg_printk(TPACPI_DBG_INIT,
157 + dbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL,
158 "bluetooth hardware not installed\n");
161 @@ -3229,7 +3253,7 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
162 res = tpacpi_new_rfkill(TPACPI_RFK_BLUETOOTH_SW_ID,
163 &tpacpi_bluetooth_rfkill,
164 RFKILL_TYPE_BLUETOOTH,
165 - "tpacpi_bluetooth_sw",
166 + TPACPI_RFK_BLUETOOTH_SW_NAME,
167 true,
168 tpacpi_bluetooth_rfk_set,
169 tpacpi_bluetooth_rfk_get);
170 @@ -3262,19 +3286,27 @@ static int bluetooth_read(char *p)
171 static int bluetooth_write(char *buf)
173 char *cmd;
174 + int state = -1;
176 if (!tp_features.bluetooth)
177 return -ENODEV;
179 while ((cmd = next_cmd(&buf))) {
180 if (strlencmp(cmd, "enable") == 0) {
181 - bluetooth_set_radiosw(1, 1);
182 + state = 1;
183 } else if (strlencmp(cmd, "disable") == 0) {
184 - bluetooth_set_radiosw(0, 1);
185 + state = 0;
186 } else
187 return -EINVAL;
190 + if (state != -1) {
191 + tpacpi_disclose_usertask("procfs bluetooth",
192 + "attempt to %s\n",
193 + state ? "enable" : "disable");
194 + bluetooth_set_radiosw(state, 1);
197 return 0;
200 @@ -3299,13 +3331,17 @@ enum {
201 off / last state */
204 +#define TPACPI_RFK_WWAN_SW_NAME "tpacpi_wwan_sw"
206 static struct rfkill *tpacpi_wan_rfkill;
208 static void wan_suspend(pm_message_t state)
210 /* Try to make sure radio will resume powered off */
211 - acpi_evalf(NULL, NULL, "\\WGSV", "qvd",
212 - TP_ACPI_WGSV_PWR_OFF_ON_RESUME);
213 + if (!acpi_evalf(NULL, NULL, "\\WGSV", "qvd",
214 + TP_ACPI_WGSV_PWR_OFF_ON_RESUME))
215 + vdbg_printk(TPACPI_DBG_RFKILL,
216 + "WWAN power down on resume request failed\n");
219 static int wan_get_radiosw(void)
220 @@ -3343,6 +3379,10 @@ static void wan_update_rfk(void)
221 if (status < 0)
222 return;
223 rfkill_force_state(tpacpi_wan_rfkill, status);
225 + vdbg_printk(TPACPI_DBG_RFKILL,
226 + "forced rfkill state to %d\n",
227 + status);
230 static int wan_set_radiosw(int radio_on, int update_rfk)
231 @@ -3358,6 +3398,9 @@ static int wan_set_radiosw(int radio_on, int update_rfk)
232 && radio_on)
233 return -EPERM;
235 + vdbg_printk(TPACPI_DBG_RFKILL,
236 + "will %s WWAN\n", radio_on ? "enable" : "disable");
238 #ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
239 if (dbg_wwanemul) {
240 tpacpi_wwan_emulstate = !!radio_on;
241 @@ -3410,6 +3453,8 @@ static ssize_t wan_enable_store(struct device *dev,
242 if (parse_strtoul(buf, 1, &t))
243 return -EINVAL;
245 + tpacpi_disclose_usertask("wwan_enable", "set to %ld\n", t);
247 res = wan_set_radiosw(t, 1);
249 return (res) ? res : count;
250 @@ -3443,6 +3488,8 @@ static int tpacpi_wan_rfk_get(void *data, enum rfkill_state *state)
252 static int tpacpi_wan_rfk_set(void *data, enum rfkill_state state)
254 + dbg_printk(TPACPI_DBG_RFKILL,
255 + "request to change radio state to %d\n", state);
256 return wan_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0);
259 @@ -3453,6 +3500,9 @@ static void wan_shutdown(void)
260 TP_ACPI_WGSV_SAVE_STATE))
261 printk(TPACPI_NOTICE
262 "failed to save WWAN state to NVRAM\n");
263 + else
264 + vdbg_printk(TPACPI_DBG_RFKILL,
265 + "WWAN state saved to NVRAM\n");
268 static void wan_exit(void)
269 @@ -3471,14 +3521,16 @@ static int __init wan_init(struct ibm_init_struct *iibm)
270 int res;
271 int status = 0;
273 - vdbg_printk(TPACPI_DBG_INIT, "initializing wan subdriver\n");
274 + vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL,
275 + "initializing wan subdriver\n");
277 TPACPI_ACPIHANDLE_INIT(hkey);
279 tp_features.wan = hkey_handle &&
280 acpi_evalf(hkey_handle, &status, "GWAN", "qd");
282 - vdbg_printk(TPACPI_DBG_INIT, "wan is %s, status 0x%02x\n",
283 + vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL,
284 + "wan is %s, status 0x%02x\n",
285 str_supported(tp_features.wan),
286 status);
288 @@ -3493,7 +3545,7 @@ static int __init wan_init(struct ibm_init_struct *iibm)
289 !(status & TP_ACPI_WANCARD_HWPRESENT)) {
290 /* no wan hardware present in system */
291 tp_features.wan = 0;
292 - dbg_printk(TPACPI_DBG_INIT,
293 + dbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL,
294 "wan hardware not installed\n");
297 @@ -3508,7 +3560,7 @@ static int __init wan_init(struct ibm_init_struct *iibm)
298 res = tpacpi_new_rfkill(TPACPI_RFK_WWAN_SW_ID,
299 &tpacpi_wan_rfkill,
300 RFKILL_TYPE_WWAN,
301 - "tpacpi_wwan_sw",
302 + TPACPI_RFK_WWAN_SW_NAME,
303 true,
304 tpacpi_wan_rfk_set,
305 tpacpi_wan_rfk_get);
306 @@ -3526,6 +3578,8 @@ static int wan_read(char *p)
307 int len = 0;
308 int status = wan_get_radiosw();
310 + tpacpi_disclose_usertask("procfs wan", "read");
312 if (!tp_features.wan)
313 len += sprintf(p + len, "status:\t\tnot supported\n");
314 else {
315 @@ -3541,19 +3595,27 @@ static int wan_read(char *p)
316 static int wan_write(char *buf)
318 char *cmd;
319 + int state = -1;
321 if (!tp_features.wan)
322 return -ENODEV;
324 while ((cmd = next_cmd(&buf))) {
325 if (strlencmp(cmd, "enable") == 0) {
326 - wan_set_radiosw(1, 1);
327 + state = 1;
328 } else if (strlencmp(cmd, "disable") == 0) {
329 - wan_set_radiosw(0, 1);
330 + state = 0;
331 } else
332 return -EINVAL;
335 + if (state != -1) {
336 + tpacpi_disclose_usertask("procfs wan",
337 + "attempt to %s\n",
338 + state ? "enable" : "disable");
339 + wan_set_radiosw(state, 1);
342 return 0;
345 @@ -3576,6 +3638,8 @@ enum {
346 TP_ACPI_UWB_RADIOSSW = 0x02, /* UWB radio enabled */
349 +#define TPACPI_RFK_UWB_SW_NAME "tpacpi_uwb_sw"
351 static struct rfkill *tpacpi_uwb_rfkill;
353 static int uwb_get_radiosw(void)
354 @@ -3613,6 +3677,10 @@ static void uwb_update_rfk(void)
355 if (status < 0)
356 return;
357 rfkill_force_state(tpacpi_uwb_rfkill, status);
359 + vdbg_printk(TPACPI_DBG_RFKILL,
360 + "forced rfkill state to %d\n",
361 + status);
364 static int uwb_set_radiosw(int radio_on, int update_rfk)
365 @@ -3628,6 +3696,9 @@ static int uwb_set_radiosw(int radio_on, int update_rfk)
366 && radio_on)
367 return -EPERM;
369 + vdbg_printk(TPACPI_DBG_RFKILL,
370 + "will %s UWB\n", radio_on ? "enable" : "disable");
372 #ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
373 if (dbg_uwbemul) {
374 tpacpi_uwb_emulstate = !!radio_on;
375 @@ -3662,6 +3733,8 @@ static int tpacpi_uwb_rfk_get(void *data, enum rfkill_state *state)
377 static int tpacpi_uwb_rfk_set(void *data, enum rfkill_state state)
379 + dbg_printk(TPACPI_DBG_RFKILL,
380 + "request to change radio state to %d\n", state);
381 return uwb_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0);
384 @@ -3676,14 +3749,16 @@ static int __init uwb_init(struct ibm_init_struct *iibm)
385 int res;
386 int status = 0;
388 - vdbg_printk(TPACPI_DBG_INIT, "initializing uwb subdriver\n");
389 + vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL,
390 + "initializing uwb subdriver\n");
392 TPACPI_ACPIHANDLE_INIT(hkey);
394 tp_features.uwb = hkey_handle &&
395 acpi_evalf(hkey_handle, &status, "GUWB", "qd");
397 - vdbg_printk(TPACPI_DBG_INIT, "uwb is %s, status 0x%02x\n",
398 + vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL,
399 + "uwb is %s, status 0x%02x\n",
400 str_supported(tp_features.uwb),
401 status);
403 @@ -3708,7 +3783,7 @@ static int __init uwb_init(struct ibm_init_struct *iibm)
404 res = tpacpi_new_rfkill(TPACPI_RFK_UWB_SW_ID,
405 &tpacpi_uwb_rfkill,
406 RFKILL_TYPE_UWB,
407 - "tpacpi_uwb_sw",
408 + TPACPI_RFK_UWB_SW_NAME,
409 false,
410 tpacpi_uwb_rfk_set,
411 tpacpi_uwb_rfk_get);
413 1.6.2.1