Add patches accepted for 2.6.22-rc1 (not released yet)
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / releases / upstream / 2.6.22-rc1 / 0020-ACPI-thinkpad-acpi-add-subdriver-debug-statements.patch
blobb17fcf811605f7167d55c9f6542d7e4e204be9cd
1 From fe08bc4b4fd1371fad111675a564e4d2ebbf39ea Mon Sep 17 00:00:00 2001
2 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
3 Date: Sat, 21 Apr 2007 11:08:32 -0300
4 Subject: ACPI: thinkpad-acpi: add subdriver debug statements
6 Add debug messages to the subdriver initialization and exit code.
8 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
9 Signed-off-by: Len Brown <len.brown@intel.com>
10 ---
11 Documentation/thinkpad-acpi.txt | 4 ++
12 drivers/misc/thinkpad_acpi.c | 111 +++++++++++++++++++++++++++++++++++++++
13 drivers/misc/thinkpad_acpi.h | 4 ++
14 3 files changed, 119 insertions(+), 0 deletions(-)
16 diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt
17 index 82fd822..20d5ec3 100644
18 --- a/Documentation/thinkpad-acpi.txt
19 +++ b/Documentation/thinkpad-acpi.txt
20 @@ -710,5 +710,9 @@ enable various classes of debugging output, for example:
21 will enable all debugging output classes. It takes a bitmask, so
22 to enable more than one output class, just add their values.
24 + Debug bitmask Description
25 + 0x0001 Initialization and probing
26 + 0x0002 Removal
28 There is also a kernel build option to enable more debugging
29 information, which may be necessary to debug driver problems.
30 diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
31 index eeab394..e8fc8da 100644
32 --- a/drivers/misc/thinkpad_acpi.c
33 +++ b/drivers/misc/thinkpad_acpi.c
34 @@ -313,6 +313,9 @@ static int __init setup_notify(struct ibm_struct *ibm)
35 if (!*ibm->handle)
36 return 0;
38 + dbg_printk(TPACPI_DBG_INIT,
39 + "setting up ACPI notify for %s\n", ibm->name);
41 ret = acpi_bus_get_device(*ibm->handle, &ibm->device);
42 if (ret < 0) {
43 printk(IBM_ERR "%s device not present\n", ibm->name);
44 @@ -349,6 +352,9 @@ static int __init register_tpacpi_subdriver(struct ibm_struct *ibm)
46 int ret;
48 + dbg_printk(TPACPI_DBG_INIT,
49 + "registering %s as an ACPI driver\n", ibm->name);
51 ibm->driver = kzalloc(sizeof(struct acpi_driver), GFP_KERNEL);
52 if (!ibm->driver) {
53 printk(IBM_ERR "kzalloc(ibm->driver) failed\n");
54 @@ -497,17 +503,25 @@ static int hotkey_orig_mask;
56 static int hotkey_init(void)
58 + vdbg_printk(TPACPI_DBG_INIT, "initializing hotkey subdriver\n");
60 IBM_HANDLE_INIT(hkey);
62 /* hotkey not supported on 570 */
63 hotkey_supported = hkey_handle != NULL;
65 + vdbg_printk(TPACPI_DBG_INIT, "hotkeys are %s\n",
66 + str_supported(hotkey_supported));
68 if (hotkey_supported) {
69 /* mask not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
70 A30, R30, R31, T20-22, X20-21, X22-24 */
71 hotkey_mask_supported =
72 acpi_evalf(hkey_handle, NULL, "DHKN", "qv");
74 + vdbg_printk(TPACPI_DBG_INIT, "hotkey masks are %s\n",
75 + str_supported(hotkey_mask_supported));
77 if (!hotkey_get(&hotkey_orig_status, &hotkey_orig_mask))
78 return -ENODEV;
80 @@ -518,6 +532,7 @@ static int hotkey_init(void)
81 static void hotkey_exit(void)
83 if (hotkey_supported) {
84 + dbg_printk(TPACPI_DBG_EXIT, "restoring original hotkey mask\n");
85 hotkey_set(hotkey_orig_status, hotkey_orig_mask);
88 @@ -633,6 +648,8 @@ static int bluetooth_supported;
90 static int bluetooth_init(void)
92 + vdbg_printk(TPACPI_DBG_INIT, "initializing bluetooth subdriver\n");
94 IBM_HANDLE_INIT(hkey);
96 /* bluetooth not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
97 @@ -640,6 +657,9 @@ static int bluetooth_init(void)
98 bluetooth_supported = hkey_handle &&
99 acpi_evalf(hkey_handle, NULL, "GBDC", "qv");
101 + vdbg_printk(TPACPI_DBG_INIT, "bluetooth is %s\n",
102 + str_supported(bluetooth_supported));
104 return (bluetooth_supported)? 0 : 1;
107 @@ -704,11 +724,16 @@ static int wan_supported;
109 static int wan_init(void)
111 + vdbg_printk(TPACPI_DBG_INIT, "initializing wan subdriver\n");
113 IBM_HANDLE_INIT(hkey);
115 wan_supported = hkey_handle &&
116 acpi_evalf(hkey_handle, NULL, "GWAN", "qv");
118 + vdbg_printk(TPACPI_DBG_INIT, "wan is %s\n",
119 + str_supported(wan_supported));
121 return (wan_supported)? 0 : 1;
124 @@ -784,6 +809,8 @@ static int video_init(void)
126 int ivga;
128 + vdbg_printk(TPACPI_DBG_INIT, "initializing video subdriver\n");
130 IBM_HANDLE_INIT(vid);
131 IBM_HANDLE_INIT(vid2);
133 @@ -804,11 +831,16 @@ static int video_init(void)
134 /* all others */
135 video_supported = TPACPI_VIDEO_NEW;
137 + vdbg_printk(TPACPI_DBG_INIT, "video is %s, mode %d\n",
138 + str_supported(video_supported != TPACPI_VIDEO_NONE),
139 + video_supported);
141 return (video_supported != TPACPI_VIDEO_NONE)? 0 : 1;
144 static void video_exit(void)
146 + dbg_printk(TPACPI_DBG_EXIT, "restoring original video autoswitch mode\n");
147 acpi_evalf(vid_handle, NULL, "_DOS", "vd", video_orig_autosw);
150 @@ -991,6 +1023,8 @@ IBM_HANDLE(ledb, ec, "LEDB"); /* G4x */
152 static int light_init(void)
154 + vdbg_printk(TPACPI_DBG_INIT, "initializing light subdriver\n");
156 IBM_HANDLE_INIT(ledb);
157 IBM_HANDLE_INIT(lght);
158 IBM_HANDLE_INIT(cmos);
159 @@ -1004,6 +1038,9 @@ static int light_init(void)
160 light_status_supported = acpi_evalf(ec_handle, NULL,
161 "KBLT", "qv");
163 + vdbg_printk(TPACPI_DBG_INIT, "light is %s\n",
164 + str_supported(light_supported));
166 return (light_supported)? 0 : 1;
169 @@ -1075,9 +1112,14 @@ IBM_HANDLE(pci, root, "\\_SB.PCI"); /* 570 */
171 static int dock_init(void)
173 + vdbg_printk(TPACPI_DBG_INIT, "initializing dock subdriver\n");
175 IBM_HANDLE_INIT(dock);
176 IBM_HANDLE_INIT(pci);
178 + vdbg_printk(TPACPI_DBG_INIT, "dock is %s\n",
179 + str_supported(dock_handle != NULL));
181 return (dock_handle)? 0 : 1;
184 @@ -1171,6 +1213,8 @@ IBM_HANDLE(bay2_ej, bay2, "_EJ3", /* 600e/x, 770e, A3x */
186 static int bay_init(void)
188 + vdbg_printk(TPACPI_DBG_INIT, "initializing bay subdriver\n");
190 IBM_HANDLE_INIT(bay);
191 if (bay_handle)
192 IBM_HANDLE_INIT(bay_ej);
193 @@ -1188,6 +1232,13 @@ static int bay_init(void)
194 bay_eject2_supported = bay2_handle && bay2_ej_handle &&
195 (strlencmp(bay2_ej_path, "_EJ0") == 0 || experimental);
197 + vdbg_printk(TPACPI_DBG_INIT,
198 + "bay 1: status %s, eject %s; bay 2: status %s, eject %s\n",
199 + str_supported(bay_status_supported),
200 + str_supported(bay_eject_supported),
201 + str_supported(bay_status2_supported),
202 + str_supported(bay_eject2_supported));
204 return (bay_status_supported || bay_eject_supported ||
205 bay_status2_supported || bay_eject2_supported)? 0 : 1;
207 @@ -1255,8 +1306,13 @@ static int bay_write(char *buf)
209 static int cmos_init(void)
211 + vdbg_printk(TPACPI_DBG_INIT,
212 + "initializing cmos commands subdriver\n");
214 IBM_HANDLE_INIT(cmos);
216 + vdbg_printk(TPACPI_DBG_INIT, "cmos commands are %s\n",
217 + str_supported(cmos_handle != NULL));
218 return (cmos_handle)? 0 : 1;
221 @@ -1320,6 +1376,8 @@ IBM_HANDLE(led, ec, "SLED", /* 570 */
223 static int led_init(void)
225 + vdbg_printk(TPACPI_DBG_INIT, "initializing LED subdriver\n");
227 IBM_HANDLE_INIT(led);
229 if (!led_handle)
230 @@ -1335,6 +1393,9 @@ static int led_init(void)
231 /* all others */
232 led_supported = TPACPI_LED_NEW;
234 + vdbg_printk(TPACPI_DBG_INIT, "LED commands are %s, mode %d\n",
235 + str_supported(led_supported), led_supported);
237 return (led_supported != TPACPI_LED_NONE)? 0 : 1;
240 @@ -1434,8 +1495,13 @@ IBM_HANDLE(beep, ec, "BEEP"); /* all except R30, R31 */
242 static int beep_init(void)
244 + vdbg_printk(TPACPI_DBG_INIT, "initializing beep subdriver\n");
246 IBM_HANDLE_INIT(beep);
248 + vdbg_printk(TPACPI_DBG_INIT, "beep is %s\n",
249 + str_supported(beep_handle != NULL));
251 return (beep_handle)? 0 : 1;
254 @@ -1486,6 +1552,8 @@ static int thermal_init(void)
255 int i;
256 int acpi_tmp7;
258 + vdbg_printk(TPACPI_DBG_INIT, "initializing thermal subdriver\n");
260 acpi_tmp7 = acpi_evalf(ec_handle, NULL, "TMP7", "qv");
262 if (ibm_thinkpad_ec_found && experimental) {
263 @@ -1542,6 +1610,10 @@ static int thermal_init(void)
264 thermal_read_mode = TPACPI_THERMAL_NONE;
267 + vdbg_printk(TPACPI_DBG_INIT, "thermal is %s, mode %d\n",
268 + str_supported(thermal_read_mode != TPACPI_THERMAL_NONE),
269 + thermal_read_mode);
271 return (thermal_read_mode != TPACPI_THERMAL_NONE)? 0 : 1;
274 @@ -1698,6 +1770,8 @@ static int brightness_init(void)
276 int b;
278 + vdbg_printk(TPACPI_DBG_INIT, "initializing brightness subdriver\n");
280 b = brightness_get(NULL);
281 if (b < 0)
282 return b;
283 @@ -1708,6 +1782,7 @@ static int brightness_init(void)
284 printk(IBM_ERR "Could not register backlight device\n");
285 return PTR_ERR(ibm_backlight_device);
287 + vdbg_printk(TPACPI_DBG_INIT, "brightness is supported\n");
289 ibm_backlight_device->props.max_brightness = 7;
290 ibm_backlight_device->props.brightness = b;
291 @@ -1719,6 +1794,8 @@ static int brightness_init(void)
292 static void brightness_exit(void)
294 if (ibm_backlight_device) {
295 + vdbg_printk(TPACPI_DBG_EXIT,
296 + "calling backlight_device_unregister()\n");
297 backlight_device_unregister(ibm_backlight_device);
298 ibm_backlight_device = NULL;
300 @@ -2017,6 +2094,8 @@ IBM_HANDLE(sfan, ec, "SFAN", /* 570 */
302 static int fan_init(void)
304 + vdbg_printk(TPACPI_DBG_INIT, "initializing fan subdriver\n");
306 fan_status_access_mode = TPACPI_FAN_NONE;
307 fan_control_access_mode = TPACPI_FAN_WR_NONE;
308 fan_control_commands = 0;
309 @@ -2095,6 +2174,11 @@ static int fan_init(void)
313 + vdbg_printk(TPACPI_DBG_INIT, "fan is %s, modes %d, %d\n",
314 + str_supported(fan_status_access_mode != TPACPI_FAN_NONE ||
315 + fan_control_access_mode != TPACPI_FAN_WR_NONE),
316 + fan_status_access_mode, fan_control_access_mode);
318 return (fan_status_access_mode != TPACPI_FAN_NONE ||
319 fan_control_access_mode != TPACPI_FAN_WR_NONE)?
320 0 : 1;
321 @@ -2138,6 +2222,7 @@ static int fan_get_status(u8 *status)
323 static void fan_exit(void)
325 + vdbg_printk(TPACPI_DBG_EXIT, "cancelling any pending watchdogs\n");
326 cancel_delayed_work(&fan_watchdog_task);
327 flush_scheduled_work();
329 @@ -2622,6 +2707,15 @@ static struct ibm_struct ibms[] = {
330 * Module and infrastructure proble, init and exit handling
333 +#ifdef CONFIG_THINKPAD_ACPI_DEBUG
334 +static const char * str_supported(int is_supported)
336 + static const char * const text_unsupported = "not supported";
338 + return (is_supported)? text_unsupported + 4 : text_unsupported;
340 +#endif /* CONFIG_THINKPAD_ACPI_DEBUG */
342 static int __init ibm_init(struct ibm_struct *ibm)
344 int ret;
345 @@ -2630,6 +2724,9 @@ static int __init ibm_init(struct ibm_struct *ibm)
346 if (ibm->experimental && !experimental)
347 return 0;
349 + dbg_printk(TPACPI_DBG_INIT,
350 + "probing for %s\n", ibm->name);
352 if (ibm->init) {
353 ret = ibm->init();
354 if (ret > 0)
355 @@ -2657,6 +2754,9 @@ static int __init ibm_init(struct ibm_struct *ibm)
356 goto err_out;
359 + dbg_printk(TPACPI_DBG_INIT,
360 + "%s installed\n", ibm->name);
362 if (ibm->read) {
363 entry = create_proc_entry(ibm->name,
364 S_IFREG | S_IRUGO | S_IWUSR,
365 @@ -2678,24 +2778,35 @@ static int __init ibm_init(struct ibm_struct *ibm)
366 return 0;
368 err_out:
369 + dbg_printk(TPACPI_DBG_INIT,
370 + "%s: at error exit path with result %d\n",
371 + ibm->name, ret);
373 ibm_exit(ibm);
374 return (ret < 0)? ret : 0;
377 static void ibm_exit(struct ibm_struct *ibm)
379 + dbg_printk(TPACPI_DBG_EXIT, "removing %s\n", ibm->name);
380 if (ibm->notify_installed) {
381 + dbg_printk(TPACPI_DBG_EXIT,
382 + "%s: acpi_remove_notify_handler\n", ibm->name);
383 acpi_remove_notify_handler(*ibm->handle, ibm->type,
384 dispatch_notify);
385 ibm->notify_installed = 0;
388 if (ibm->proc_created) {
389 + dbg_printk(TPACPI_DBG_EXIT,
390 + "%s: remove_proc_entry\n", ibm->name);
391 remove_proc_entry(ibm->name, proc_dir);
392 ibm->proc_created = 0;
395 if (ibm->driver_registered) {
396 + dbg_printk(TPACPI_DBG_EXIT,
397 + "%s: acpi_bus_unregister_driver\n", ibm->name);
398 acpi_bus_unregister_driver(ibm->driver);
399 kfree(ibm->driver);
400 ibm->driver = NULL;
401 diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
402 index 06d4c38..beb1447 100644
403 --- a/drivers/misc/thinkpad_acpi.h
404 +++ b/drivers/misc/thinkpad_acpi.h
405 @@ -76,12 +76,16 @@
407 /* Debugging */
408 #define TPACPI_DBG_ALL 0xffff
409 +#define TPACPI_DBG_ALL 0xffff
410 +#define TPACPI_DBG_INIT 0x0001
411 +#define TPACPI_DBG_EXIT 0x0002
412 #define dbg_printk(a_dbg_level, format, arg...) \
413 do { if (dbg_level & a_dbg_level) \
414 printk(IBM_DEBUG "%s: " format, __func__ , ## arg); } while (0)
415 #ifdef CONFIG_THINKPAD_ACPI_DEBUG
416 #define vdbg_printk(a_dbg_level, format, arg...) \
417 dbg_printk(a_dbg_level, format, ## arg)
418 +static const char *str_supported(int is_supported);
419 #else
420 #define vdbg_printk(a_dbg_level, format, arg...)
421 #endif
423 1.5.1