aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/uhci-hcd.c
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2005-12-17 18:03:37 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-20 17:49:57 -0500
commit8d402e1ae03656c1ad215514f8885ef4793f0948 (patch)
treeceac7800d7e07be1a7320a0b729156b12fbf26d6 /drivers/usb/host/uhci-hcd.c
parent0ed8fee1c1d38a62e981025ba40b5eba30c4ce2a (diff)
[PATCH] UHCI: improve debugging code
This patch (as626) makes some improvements to the debugging code in uhci-hcd. The main change is that now the code won't get compiled if CONFIG_USB_DEBUG isn't set. But there are other changes too, like adding a missing .owner field and printing a debugging dump if the controller dies. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host/uhci-hcd.c')
-rw-r--r--drivers/usb/host/uhci-hcd.c60
1 files changed, 39 insertions, 21 deletions
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index 9865f303d3fc..4edb8330c440 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -68,12 +68,16 @@ Alan Stern"
68 * debug = 3, show all TDs in URBs when dumping 68 * debug = 3, show all TDs in URBs when dumping
69 */ 69 */
70#ifdef DEBUG 70#ifdef DEBUG
71#define DEBUG_CONFIGURED 1
71static int debug = 1; 72static int debug = 1;
72#else
73static int debug = 0;
74#endif
75module_param(debug, int, S_IRUGO | S_IWUSR); 73module_param(debug, int, S_IRUGO | S_IWUSR);
76MODULE_PARM_DESC(debug, "Debug level"); 74MODULE_PARM_DESC(debug, "Debug level");
75
76#else
77#define DEBUG_CONFIGURED 0
78#define debug 0
79#endif
80
77static char *errbuf; 81static char *errbuf;
78#define ERRBUF_LEN (32 * 1024) 82#define ERRBUF_LEN (32 * 1024)
79 83
@@ -338,6 +342,12 @@ static irqreturn_t uhci_irq(struct usb_hcd *hcd, struct pt_regs *regs)
338 dev_err(uhci_dev(uhci), 342 dev_err(uhci_dev(uhci),
339 "host controller halted, " 343 "host controller halted, "
340 "very bad!\n"); 344 "very bad!\n");
345 if (debug > 1 && errbuf) {
346 /* Print the schedule for debugging */
347 uhci_sprint_schedule(uhci,
348 errbuf, ERRBUF_LEN);
349 lprintk(errbuf);
350 }
341 hc_died(uhci); 351 hc_died(uhci);
342 352
343 /* Force a callback in case there are 353 /* Force a callback in case there are
@@ -376,6 +386,14 @@ static void release_uhci(struct uhci_hcd *uhci)
376{ 386{
377 int i; 387 int i;
378 388
389 if (DEBUG_CONFIGURED) {
390 spin_lock_irq(&uhci->lock);
391 uhci->is_initialized = 0;
392 spin_unlock_irq(&uhci->lock);
393
394 debugfs_remove(uhci->dentry);
395 }
396
379 for (i = 0; i < UHCI_NUM_SKELQH; i++) 397 for (i = 0; i < UHCI_NUM_SKELQH; i++)
380 uhci_free_qh(uhci, uhci->skelqh[i]); 398 uhci_free_qh(uhci, uhci->skelqh[i]);
381 399
@@ -390,8 +408,6 @@ static void release_uhci(struct uhci_hcd *uhci)
390 dma_free_coherent(uhci_dev(uhci), 408 dma_free_coherent(uhci_dev(uhci),
391 UHCI_NUMFRAMES * sizeof(*uhci->frame), 409 UHCI_NUMFRAMES * sizeof(*uhci->frame),
392 uhci->frame, uhci->frame_dma_handle); 410 uhci->frame, uhci->frame_dma_handle);
393
394 debugfs_remove(uhci->dentry);
395} 411}
396 412
397static int uhci_reset(struct usb_hcd *hcd) 413static int uhci_reset(struct usb_hcd *hcd)
@@ -474,17 +490,6 @@ static int uhci_start(struct usb_hcd *hcd)
474 490
475 hcd->uses_new_polling = 1; 491 hcd->uses_new_polling = 1;
476 492
477 dentry = debugfs_create_file(hcd->self.bus_name,
478 S_IFREG|S_IRUGO|S_IWUSR, uhci_debugfs_root, uhci,
479 &uhci_debug_operations);
480 if (!dentry) {
481 dev_err(uhci_dev(uhci),
482 "couldn't create uhci debugfs entry\n");
483 retval = -ENOMEM;
484 goto err_create_debug_entry;
485 }
486 uhci->dentry = dentry;
487
488 uhci->fsbr = 0; 493 uhci->fsbr = 0;
489 uhci->fsbrtimeout = 0; 494 uhci->fsbrtimeout = 0;
490 495
@@ -495,6 +500,19 @@ static int uhci_start(struct usb_hcd *hcd)
495 500
496 init_waitqueue_head(&uhci->waitqh); 501 init_waitqueue_head(&uhci->waitqh);
497 502
503 if (DEBUG_CONFIGURED) {
504 dentry = debugfs_create_file(hcd->self.bus_name,
505 S_IFREG|S_IRUGO|S_IWUSR, uhci_debugfs_root,
506 uhci, &uhci_debug_operations);
507 if (!dentry) {
508 dev_err(uhci_dev(uhci), "couldn't create uhci "
509 "debugfs entry\n");
510 retval = -ENOMEM;
511 goto err_create_debug_entry;
512 }
513 uhci->dentry = dentry;
514 }
515
498 uhci->frame = dma_alloc_coherent(uhci_dev(uhci), 516 uhci->frame = dma_alloc_coherent(uhci_dev(uhci),
499 UHCI_NUMFRAMES * sizeof(*uhci->frame), 517 UHCI_NUMFRAMES * sizeof(*uhci->frame),
500 &uhci->frame_dma_handle, 0); 518 &uhci->frame_dma_handle, 0);
@@ -609,6 +627,7 @@ static int uhci_start(struct usb_hcd *hcd)
609 mb(); 627 mb();
610 628
611 configure_hc(uhci); 629 configure_hc(uhci);
630 uhci->is_initialized = 1;
612 start_rh(uhci); 631 start_rh(uhci);
613 return 0; 632 return 0;
614 633
@@ -872,16 +891,15 @@ static int __init uhci_hcd_init(void)
872 if (usb_disabled()) 891 if (usb_disabled())
873 return -ENODEV; 892 return -ENODEV;
874 893
875 if (debug) { 894 if (DEBUG_CONFIGURED) {
876 errbuf = kmalloc(ERRBUF_LEN, GFP_KERNEL); 895 errbuf = kmalloc(ERRBUF_LEN, GFP_KERNEL);
877 if (!errbuf) 896 if (!errbuf)
878 goto errbuf_failed; 897 goto errbuf_failed;
898 uhci_debugfs_root = debugfs_create_dir("uhci", NULL);
899 if (!uhci_debugfs_root)
900 goto debug_failed;
879 } 901 }
880 902
881 uhci_debugfs_root = debugfs_create_dir("uhci", NULL);
882 if (!uhci_debugfs_root)
883 goto debug_failed;
884
885 uhci_up_cachep = kmem_cache_create("uhci_urb_priv", 903 uhci_up_cachep = kmem_cache_create("uhci_urb_priv",
886 sizeof(struct urb_priv), 0, 0, NULL, NULL); 904 sizeof(struct urb_priv), 0, 0, NULL, NULL);
887 if (!uhci_up_cachep) 905 if (!uhci_up_cachep)