diff options
| author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-03-23 23:44:19 -0500 |
|---|---|---|
| committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-03-23 23:44:19 -0500 |
| commit | 1ebbe2b20091d306453a5cf480a87e6cd28ae76f (patch) | |
| tree | f5cd7a0fa69b8b1938cb5a0faed2e7b0628072a5 /drivers/usb/host/uhci-debug.c | |
| parent | ac58c9059da8886b5e8cde012a80266b18ca146e (diff) | |
| parent | 674a396c6d2ba0341ebdd7c1c9950f32f018e2dd (diff) | |
Merge branch 'linus'
Diffstat (limited to 'drivers/usb/host/uhci-debug.c')
| -rw-r--r-- | drivers/usb/host/uhci-debug.c | 356 |
1 files changed, 123 insertions, 233 deletions
diff --git a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c index 5832953086f8..e1239319655c 100644 --- a/drivers/usb/host/uhci-debug.c +++ b/drivers/usb/host/uhci-debug.c | |||
| @@ -17,10 +17,13 @@ | |||
| 17 | 17 | ||
| 18 | #include "uhci-hcd.h" | 18 | #include "uhci-hcd.h" |
| 19 | 19 | ||
| 20 | static struct dentry *uhci_debugfs_root = NULL; | 20 | #define uhci_debug_operations (* (struct file_operations *) NULL) |
| 21 | static struct dentry *uhci_debugfs_root; | ||
| 22 | |||
| 23 | #ifdef DEBUG | ||
| 21 | 24 | ||
| 22 | /* Handle REALLY large printks so we don't overflow buffers */ | 25 | /* Handle REALLY large printks so we don't overflow buffers */ |
| 23 | static inline void lprintk(char *buf) | 26 | static void lprintk(char *buf) |
| 24 | { | 27 | { |
| 25 | char *p; | 28 | char *p; |
| 26 | 29 | ||
| @@ -90,13 +93,59 @@ static int uhci_show_td(struct uhci_td *td, char *buf, int len, int space) | |||
| 90 | return out - buf; | 93 | return out - buf; |
| 91 | } | 94 | } |
| 92 | 95 | ||
| 93 | static int uhci_show_qh(struct uhci_qh *qh, char *buf, int len, int space) | 96 | static int uhci_show_urbp(struct urb_priv *urbp, char *buf, int len, int space) |
| 94 | { | 97 | { |
| 95 | char *out = buf; | 98 | char *out = buf; |
| 96 | struct urb_priv *urbp; | ||
| 97 | struct list_head *head, *tmp; | ||
| 98 | struct uhci_td *td; | 99 | struct uhci_td *td; |
| 99 | int i = 0, checked = 0, prevactive = 0; | 100 | int i, nactive, ninactive; |
| 101 | |||
| 102 | if (len < 200) | ||
| 103 | return 0; | ||
| 104 | |||
| 105 | out += sprintf(out, "urb_priv [%p] ", urbp); | ||
| 106 | out += sprintf(out, "urb [%p] ", urbp->urb); | ||
| 107 | out += sprintf(out, "qh [%p] ", urbp->qh); | ||
| 108 | out += sprintf(out, "Dev=%d ", usb_pipedevice(urbp->urb->pipe)); | ||
| 109 | out += sprintf(out, "EP=%x(%s) ", usb_pipeendpoint(urbp->urb->pipe), | ||
| 110 | (usb_pipein(urbp->urb->pipe) ? "IN" : "OUT")); | ||
| 111 | |||
| 112 | switch (usb_pipetype(urbp->urb->pipe)) { | ||
| 113 | case PIPE_ISOCHRONOUS: out += sprintf(out, "ISO"); break; | ||
| 114 | case PIPE_INTERRUPT: out += sprintf(out, "INT"); break; | ||
| 115 | case PIPE_BULK: out += sprintf(out, "BLK"); break; | ||
| 116 | case PIPE_CONTROL: out += sprintf(out, "CTL"); break; | ||
| 117 | } | ||
| 118 | |||
| 119 | out += sprintf(out, "%s", (urbp->fsbr ? " FSBR" : "")); | ||
| 120 | |||
| 121 | if (urbp->urb->status != -EINPROGRESS) | ||
| 122 | out += sprintf(out, " Status=%d", urbp->urb->status); | ||
| 123 | out += sprintf(out, "\n"); | ||
| 124 | |||
| 125 | i = nactive = ninactive = 0; | ||
| 126 | list_for_each_entry(td, &urbp->td_list, list) { | ||
| 127 | if (++i <= 10 || debug > 2) { | ||
| 128 | out += sprintf(out, "%*s%d: ", space + 2, "", i); | ||
| 129 | out += uhci_show_td(td, out, len - (out - buf), 0); | ||
| 130 | } else { | ||
| 131 | if (td_status(td) & TD_CTRL_ACTIVE) | ||
| 132 | ++nactive; | ||
| 133 | else | ||
| 134 | ++ninactive; | ||
| 135 | } | ||
| 136 | } | ||
| 137 | if (nactive + ninactive > 0) | ||
| 138 | out += sprintf(out, "%*s[skipped %d inactive and %d active " | ||
| 139 | "TDs]\n", | ||
| 140 | space, "", ninactive, nactive); | ||
| 141 | |||
| 142 | return out - buf; | ||
| 143 | } | ||
| 144 | |||
| 145 | static int uhci_show_qh(struct uhci_qh *qh, char *buf, int len, int space) | ||
| 146 | { | ||
| 147 | char *out = buf; | ||
| 148 | int i, nurbs; | ||
| 100 | __le32 element = qh_element(qh); | 149 | __le32 element = qh_element(qh); |
| 101 | 150 | ||
| 102 | /* Try to make sure there's enough memory */ | 151 | /* Try to make sure there's enough memory */ |
| @@ -118,86 +167,40 @@ static int uhci_show_qh(struct uhci_qh *qh, char *buf, int len, int space) | |||
| 118 | if (!(element & ~(UHCI_PTR_QH | UHCI_PTR_DEPTH))) | 167 | if (!(element & ~(UHCI_PTR_QH | UHCI_PTR_DEPTH))) |
| 119 | out += sprintf(out, "%*s Element is NULL (bug?)\n", space, ""); | 168 | out += sprintf(out, "%*s Element is NULL (bug?)\n", space, ""); |
| 120 | 169 | ||
| 121 | if (!qh->urbp) { | 170 | if (list_empty(&qh->queue)) { |
| 122 | out += sprintf(out, "%*s urbp == NULL\n", space, ""); | 171 | out += sprintf(out, "%*s queue is empty\n", space, ""); |
| 123 | goto out; | 172 | } else { |
| 124 | } | 173 | struct urb_priv *urbp = list_entry(qh->queue.next, |
| 125 | 174 | struct urb_priv, node); | |
| 126 | urbp = qh->urbp; | 175 | struct uhci_td *td = list_entry(urbp->td_list.next, |
| 127 | 176 | struct uhci_td, list); | |
| 128 | head = &urbp->td_list; | 177 | |
| 129 | tmp = head->next; | 178 | if (cpu_to_le32(td->dma_handle) != (element & ~UHCI_PTR_BITS)) |
| 130 | 179 | out += sprintf(out, "%*s Element != First TD\n", | |
| 131 | td = list_entry(tmp, struct uhci_td, list); | 180 | space, ""); |
| 132 | 181 | i = nurbs = 0; | |
| 133 | if (cpu_to_le32(td->dma_handle) != (element & ~UHCI_PTR_BITS)) | 182 | list_for_each_entry(urbp, &qh->queue, node) { |
| 134 | out += sprintf(out, "%*s Element != First TD\n", space, ""); | 183 | if (++i <= 10) |
| 135 | 184 | out += uhci_show_urbp(urbp, out, | |
| 136 | while (tmp != head) { | 185 | len - (out - buf), space + 2); |
| 137 | struct uhci_td *td = list_entry(tmp, struct uhci_td, list); | 186 | else |
| 138 | 187 | ++nurbs; | |
| 139 | tmp = tmp->next; | ||
| 140 | |||
| 141 | out += sprintf(out, "%*s%d: ", space + 2, "", i++); | ||
| 142 | out += uhci_show_td(td, out, len - (out - buf), 0); | ||
| 143 | |||
| 144 | if (i > 10 && !checked && prevactive && tmp != head && | ||
| 145 | debug <= 2) { | ||
| 146 | struct list_head *ntmp = tmp; | ||
| 147 | struct uhci_td *ntd = td; | ||
| 148 | int active = 1, ni = i; | ||
| 149 | |||
| 150 | checked = 1; | ||
| 151 | |||
| 152 | while (ntmp != head && ntmp->next != head && active) { | ||
| 153 | ntd = list_entry(ntmp, struct uhci_td, list); | ||
| 154 | |||
| 155 | ntmp = ntmp->next; | ||
| 156 | |||
| 157 | active = td_status(ntd) & TD_CTRL_ACTIVE; | ||
| 158 | |||
| 159 | ni++; | ||
| 160 | } | ||
| 161 | |||
| 162 | if (active && ni > i) { | ||
| 163 | out += sprintf(out, "%*s[skipped %d active TDs]\n", space, "", ni - i); | ||
| 164 | tmp = ntmp; | ||
| 165 | td = ntd; | ||
| 166 | i = ni; | ||
| 167 | } | ||
| 168 | } | 188 | } |
| 169 | 189 | if (nurbs > 0) | |
| 170 | prevactive = td_status(td) & TD_CTRL_ACTIVE; | 190 | out += sprintf(out, "%*s Skipped %d URBs\n", |
| 191 | space, "", nurbs); | ||
| 171 | } | 192 | } |
| 172 | 193 | ||
| 173 | if (list_empty(&urbp->queue_list) || urbp->queued) | 194 | if (qh->udev) { |
| 174 | goto out; | 195 | out += sprintf(out, "%*s Dummy TD\n", space, ""); |
| 175 | 196 | out += uhci_show_td(qh->dummy_td, out, len - (out - buf), 0); | |
| 176 | out += sprintf(out, "%*sQueued QHs:\n", -space, "--"); | ||
| 177 | |||
| 178 | head = &urbp->queue_list; | ||
| 179 | tmp = head->next; | ||
| 180 | |||
| 181 | while (tmp != head) { | ||
| 182 | struct urb_priv *nurbp = list_entry(tmp, struct urb_priv, | ||
| 183 | queue_list); | ||
| 184 | tmp = tmp->next; | ||
| 185 | |||
| 186 | out += uhci_show_qh(nurbp->qh, out, len - (out - buf), space); | ||
| 187 | } | 197 | } |
| 188 | 198 | ||
| 189 | out: | ||
| 190 | return out - buf; | 199 | return out - buf; |
| 191 | } | 200 | } |
| 192 | 201 | ||
| 193 | #define show_frame_num() \ | ||
| 194 | if (!shown) { \ | ||
| 195 | shown = 1; \ | ||
| 196 | out += sprintf(out, "- Frame %d\n", i); \ | ||
| 197 | } | ||
| 198 | |||
| 199 | #ifdef CONFIG_PROC_FS | ||
| 200 | static const char * const qh_names[] = { | 202 | static const char * const qh_names[] = { |
| 203 | "skel_unlink_qh", "skel_iso_qh", | ||
| 201 | "skel_int128_qh", "skel_int64_qh", | 204 | "skel_int128_qh", "skel_int64_qh", |
| 202 | "skel_int32_qh", "skel_int16_qh", | 205 | "skel_int32_qh", "skel_int16_qh", |
| 203 | "skel_int8_qh", "skel_int4_qh", | 206 | "skel_int8_qh", "skel_int4_qh", |
| @@ -206,12 +209,6 @@ static const char * const qh_names[] = { | |||
| 206 | "skel_bulk_qh", "skel_term_qh" | 209 | "skel_bulk_qh", "skel_term_qh" |
| 207 | }; | 210 | }; |
| 208 | 211 | ||
| 209 | #define show_qh_name() \ | ||
| 210 | if (!shown) { \ | ||
| 211 | shown = 1; \ | ||
| 212 | out += sprintf(out, "- %s\n", qh_names[i]); \ | ||
| 213 | } | ||
| 214 | |||
| 215 | static int uhci_show_sc(int port, unsigned short status, char *buf, int len) | 212 | static int uhci_show_sc(int port, unsigned short status, char *buf, int len) |
| 216 | { | 213 | { |
| 217 | char *out = buf; | 214 | char *out = buf; |
| @@ -321,139 +318,29 @@ static int uhci_show_status(struct uhci_hcd *uhci, char *buf, int len) | |||
| 321 | return out - buf; | 318 | return out - buf; |
| 322 | } | 319 | } |
| 323 | 320 | ||
| 324 | static int uhci_show_urbp(struct uhci_hcd *uhci, struct urb_priv *urbp, char *buf, int len) | ||
| 325 | { | ||
| 326 | struct list_head *tmp; | ||
| 327 | char *out = buf; | ||
| 328 | int count = 0; | ||
| 329 | |||
| 330 | if (len < 200) | ||
| 331 | return 0; | ||
| 332 | |||
| 333 | out += sprintf(out, "urb_priv [%p] ", urbp); | ||
| 334 | out += sprintf(out, "urb [%p] ", urbp->urb); | ||
| 335 | out += sprintf(out, "qh [%p] ", urbp->qh); | ||
| 336 | out += sprintf(out, "Dev=%d ", usb_pipedevice(urbp->urb->pipe)); | ||
| 337 | out += sprintf(out, "EP=%x(%s) ", usb_pipeendpoint(urbp->urb->pipe), (usb_pipein(urbp->urb->pipe) ? "IN" : "OUT")); | ||
| 338 | |||
| 339 | switch (usb_pipetype(urbp->urb->pipe)) { | ||
| 340 | case PIPE_ISOCHRONOUS: out += sprintf(out, "ISO "); break; | ||
| 341 | case PIPE_INTERRUPT: out += sprintf(out, "INT "); break; | ||
| 342 | case PIPE_BULK: out += sprintf(out, "BLK "); break; | ||
| 343 | case PIPE_CONTROL: out += sprintf(out, "CTL "); break; | ||
| 344 | } | ||
| 345 | |||
| 346 | out += sprintf(out, "%s", (urbp->fsbr ? "FSBR " : "")); | ||
| 347 | out += sprintf(out, "%s", (urbp->fsbr_timeout ? "FSBR_TO " : "")); | ||
| 348 | |||
| 349 | if (urbp->urb->status != -EINPROGRESS) | ||
| 350 | out += sprintf(out, "Status=%d ", urbp->urb->status); | ||
| 351 | //out += sprintf(out, "FSBRtime=%lx ",urbp->fsbrtime); | ||
| 352 | |||
| 353 | count = 0; | ||
| 354 | list_for_each(tmp, &urbp->td_list) | ||
| 355 | count++; | ||
| 356 | out += sprintf(out, "TDs=%d ",count); | ||
| 357 | |||
| 358 | if (urbp->queued) | ||
| 359 | out += sprintf(out, "queued\n"); | ||
| 360 | else { | ||
| 361 | count = 0; | ||
| 362 | list_for_each(tmp, &urbp->queue_list) | ||
| 363 | count++; | ||
| 364 | out += sprintf(out, "queued URBs=%d\n", count); | ||
| 365 | } | ||
| 366 | |||
| 367 | return out - buf; | ||
| 368 | } | ||
| 369 | |||
| 370 | static int uhci_show_lists(struct uhci_hcd *uhci, char *buf, int len) | ||
| 371 | { | ||
| 372 | char *out = buf; | ||
| 373 | struct list_head *head, *tmp; | ||
| 374 | int count; | ||
| 375 | |||
| 376 | out += sprintf(out, "Main list URBs:"); | ||
| 377 | if (list_empty(&uhci->urb_list)) | ||
| 378 | out += sprintf(out, " Empty\n"); | ||
| 379 | else { | ||
| 380 | out += sprintf(out, "\n"); | ||
| 381 | count = 0; | ||
| 382 | head = &uhci->urb_list; | ||
| 383 | tmp = head->next; | ||
| 384 | while (tmp != head) { | ||
| 385 | struct urb_priv *urbp = list_entry(tmp, struct urb_priv, urb_list); | ||
| 386 | |||
| 387 | out += sprintf(out, " %d: ", ++count); | ||
| 388 | out += uhci_show_urbp(uhci, urbp, out, len - (out - buf)); | ||
| 389 | tmp = tmp->next; | ||
| 390 | } | ||
| 391 | } | ||
| 392 | |||
| 393 | out += sprintf(out, "Remove list URBs:"); | ||
| 394 | if (list_empty(&uhci->urb_remove_list)) | ||
| 395 | out += sprintf(out, " Empty\n"); | ||
| 396 | else { | ||
| 397 | out += sprintf(out, "\n"); | ||
| 398 | count = 0; | ||
| 399 | head = &uhci->urb_remove_list; | ||
| 400 | tmp = head->next; | ||
| 401 | while (tmp != head) { | ||
| 402 | struct urb_priv *urbp = list_entry(tmp, struct urb_priv, urb_list); | ||
| 403 | |||
| 404 | out += sprintf(out, " %d: ", ++count); | ||
| 405 | out += uhci_show_urbp(uhci, urbp, out, len - (out - buf)); | ||
| 406 | tmp = tmp->next; | ||
| 407 | } | ||
| 408 | } | ||
| 409 | |||
| 410 | out += sprintf(out, "Complete list URBs:"); | ||
| 411 | if (list_empty(&uhci->complete_list)) | ||
| 412 | out += sprintf(out, " Empty\n"); | ||
| 413 | else { | ||
| 414 | out += sprintf(out, "\n"); | ||
| 415 | count = 0; | ||
| 416 | head = &uhci->complete_list; | ||
| 417 | tmp = head->next; | ||
| 418 | while (tmp != head) { | ||
| 419 | struct urb_priv *urbp = list_entry(tmp, struct urb_priv, urb_list); | ||
| 420 | |||
| 421 | out += sprintf(out, " %d: ", ++count); | ||
| 422 | out += uhci_show_urbp(uhci, urbp, out, len - (out - buf)); | ||
| 423 | tmp = tmp->next; | ||
| 424 | } | ||
| 425 | } | ||
| 426 | |||
| 427 | return out - buf; | ||
| 428 | } | ||
| 429 | |||
| 430 | static int uhci_sprint_schedule(struct uhci_hcd *uhci, char *buf, int len) | 321 | static int uhci_sprint_schedule(struct uhci_hcd *uhci, char *buf, int len) |
| 431 | { | 322 | { |
| 432 | unsigned long flags; | ||
| 433 | char *out = buf; | 323 | char *out = buf; |
| 434 | int i, j; | 324 | int i, j; |
| 435 | struct uhci_qh *qh; | 325 | struct uhci_qh *qh; |
| 436 | struct uhci_td *td; | 326 | struct uhci_td *td; |
| 437 | struct list_head *tmp, *head; | 327 | struct list_head *tmp, *head; |
| 438 | 328 | ||
| 439 | spin_lock_irqsave(&uhci->lock, flags); | ||
| 440 | |||
| 441 | out += uhci_show_root_hub_state(uhci, out, len - (out - buf)); | 329 | out += uhci_show_root_hub_state(uhci, out, len - (out - buf)); |
| 442 | out += sprintf(out, "HC status\n"); | 330 | out += sprintf(out, "HC status\n"); |
| 443 | out += uhci_show_status(uhci, out, len - (out - buf)); | 331 | out += uhci_show_status(uhci, out, len - (out - buf)); |
| 332 | if (debug <= 1) | ||
| 333 | return out - buf; | ||
| 444 | 334 | ||
| 445 | out += sprintf(out, "Frame List\n"); | 335 | out += sprintf(out, "Frame List\n"); |
| 446 | for (i = 0; i < UHCI_NUMFRAMES; ++i) { | 336 | for (i = 0; i < UHCI_NUMFRAMES; ++i) { |
| 447 | int shown = 0; | ||
| 448 | td = uhci->frame_cpu[i]; | 337 | td = uhci->frame_cpu[i]; |
| 449 | if (!td) | 338 | if (!td) |
| 450 | continue; | 339 | continue; |
| 451 | 340 | ||
| 452 | if (td->dma_handle != (dma_addr_t)uhci->frame[i]) { | 341 | out += sprintf(out, "- Frame %d\n", i); \ |
| 453 | show_frame_num(); | 342 | if (td->dma_handle != (dma_addr_t)uhci->frame[i]) |
| 454 | out += sprintf(out, " frame list does not match td->dma_handle!\n"); | 343 | out += sprintf(out, " frame list does not match td->dma_handle!\n"); |
| 455 | } | ||
| 456 | show_frame_num(); | ||
| 457 | 344 | ||
| 458 | head = &td->fl_list; | 345 | head = &td->fl_list; |
| 459 | tmp = head; | 346 | tmp = head; |
| @@ -467,14 +354,11 @@ static int uhci_sprint_schedule(struct uhci_hcd *uhci, char *buf, int len) | |||
| 467 | out += sprintf(out, "Skeleton QHs\n"); | 354 | out += sprintf(out, "Skeleton QHs\n"); |
| 468 | 355 | ||
| 469 | for (i = 0; i < UHCI_NUM_SKELQH; ++i) { | 356 | for (i = 0; i < UHCI_NUM_SKELQH; ++i) { |
| 470 | int shown = 0; | 357 | int cnt = 0; |
| 471 | 358 | ||
| 472 | qh = uhci->skelqh[i]; | 359 | qh = uhci->skelqh[i]; |
| 473 | 360 | out += sprintf(out, "- %s\n", qh_names[i]); \ | |
| 474 | if (debug > 1) { | 361 | out += uhci_show_qh(qh, out, len - (out - buf), 4); |
| 475 | show_qh_name(); | ||
| 476 | out += uhci_show_qh(qh, out, len - (out - buf), 4); | ||
| 477 | } | ||
| 478 | 362 | ||
| 479 | /* Last QH is the Terminating QH, it's different */ | 363 | /* Last QH is the Terminating QH, it's different */ |
| 480 | if (i == UHCI_NUM_SKELQH - 1) { | 364 | if (i == UHCI_NUM_SKELQH - 1) { |
| @@ -487,53 +371,37 @@ static int uhci_sprint_schedule(struct uhci_hcd *uhci, char *buf, int len) | |||
| 487 | continue; | 371 | continue; |
| 488 | } | 372 | } |
| 489 | 373 | ||
| 490 | j = (i < 7) ? 7 : i+1; /* Next skeleton */ | 374 | j = (i < 9) ? 9 : i+1; /* Next skeleton */ |
| 491 | if (list_empty(&qh->list)) { | 375 | head = &qh->node; |
| 492 | if (i < UHCI_NUM_SKELQH - 1) { | ||
| 493 | if (qh->link != | ||
| 494 | (cpu_to_le32(uhci->skelqh[j]->dma_handle) | UHCI_PTR_QH)) { | ||
| 495 | show_qh_name(); | ||
| 496 | out += sprintf(out, " skeleton QH not linked to next skeleton QH!\n"); | ||
| 497 | } | ||
| 498 | } | ||
| 499 | |||
| 500 | continue; | ||
| 501 | } | ||
| 502 | |||
| 503 | show_qh_name(); | ||
| 504 | |||
| 505 | head = &qh->list; | ||
| 506 | tmp = head->next; | 376 | tmp = head->next; |
| 507 | 377 | ||
| 508 | while (tmp != head) { | 378 | while (tmp != head) { |
| 509 | qh = list_entry(tmp, struct uhci_qh, list); | 379 | qh = list_entry(tmp, struct uhci_qh, node); |
| 510 | |||
| 511 | tmp = tmp->next; | 380 | tmp = tmp->next; |
| 512 | 381 | if (++cnt <= 10) | |
| 513 | out += uhci_show_qh(qh, out, len - (out - buf), 4); | 382 | out += uhci_show_qh(qh, out, |
| 383 | len - (out - buf), 4); | ||
| 514 | } | 384 | } |
| 385 | if ((cnt -= 10) > 0) | ||
| 386 | out += sprintf(out, " Skipped %d QHs\n", cnt); | ||
| 515 | 387 | ||
| 516 | if (i < UHCI_NUM_SKELQH - 1) { | 388 | if (i > 1 && i < UHCI_NUM_SKELQH - 1) { |
| 517 | if (qh->link != | 389 | if (qh->link != |
| 518 | (cpu_to_le32(uhci->skelqh[j]->dma_handle) | UHCI_PTR_QH)) | 390 | (cpu_to_le32(uhci->skelqh[j]->dma_handle) | UHCI_PTR_QH)) |
| 519 | out += sprintf(out, " last QH not linked to next skeleton!\n"); | 391 | out += sprintf(out, " last QH not linked to next skeleton!\n"); |
| 520 | } | 392 | } |
| 521 | } | 393 | } |
| 522 | 394 | ||
| 523 | if (debug > 2) | ||
| 524 | out += uhci_show_lists(uhci, out, len - (out - buf)); | ||
| 525 | |||
| 526 | spin_unlock_irqrestore(&uhci->lock, flags); | ||
| 527 | |||
| 528 | return out - buf; | 395 | return out - buf; |
| 529 | } | 396 | } |
| 530 | 397 | ||
| 398 | #ifdef CONFIG_DEBUG_FS | ||
| 399 | |||
| 531 | #define MAX_OUTPUT (64 * 1024) | 400 | #define MAX_OUTPUT (64 * 1024) |
| 532 | 401 | ||
| 533 | struct uhci_debug { | 402 | struct uhci_debug { |
| 534 | int size; | 403 | int size; |
| 535 | char *data; | 404 | char *data; |
| 536 | struct uhci_hcd *uhci; | ||
| 537 | }; | 405 | }; |
| 538 | 406 | ||
| 539 | static int uhci_debug_open(struct inode *inode, struct file *file) | 407 | static int uhci_debug_open(struct inode *inode, struct file *file) |
| @@ -541,6 +409,7 @@ static int uhci_debug_open(struct inode *inode, struct file *file) | |||
| 541 | struct uhci_hcd *uhci = inode->u.generic_ip; | 409 | struct uhci_hcd *uhci = inode->u.generic_ip; |
| 542 | struct uhci_debug *up; | 410 | struct uhci_debug *up; |
| 543 | int ret = -ENOMEM; | 411 | int ret = -ENOMEM; |
| 412 | unsigned long flags; | ||
| 544 | 413 | ||
| 545 | lock_kernel(); | 414 | lock_kernel(); |
| 546 | up = kmalloc(sizeof(*up), GFP_KERNEL); | 415 | up = kmalloc(sizeof(*up), GFP_KERNEL); |
| @@ -553,7 +422,11 @@ static int uhci_debug_open(struct inode *inode, struct file *file) | |||
| 553 | goto out; | 422 | goto out; |
| 554 | } | 423 | } |
| 555 | 424 | ||
| 556 | up->size = uhci_sprint_schedule(uhci, up->data, MAX_OUTPUT); | 425 | up->size = 0; |
| 426 | spin_lock_irqsave(&uhci->lock, flags); | ||
| 427 | if (uhci->is_initialized) | ||
| 428 | up->size = uhci_sprint_schedule(uhci, up->data, MAX_OUTPUT); | ||
| 429 | spin_unlock_irqrestore(&uhci->lock, flags); | ||
| 557 | 430 | ||
| 558 | file->private_data = up; | 431 | file->private_data = up; |
| 559 | 432 | ||
| @@ -604,15 +477,32 @@ static int uhci_debug_release(struct inode *inode, struct file *file) | |||
| 604 | return 0; | 477 | return 0; |
| 605 | } | 478 | } |
| 606 | 479 | ||
| 480 | #undef uhci_debug_operations | ||
| 607 | static struct file_operations uhci_debug_operations = { | 481 | static struct file_operations uhci_debug_operations = { |
| 482 | .owner = THIS_MODULE, | ||
| 608 | .open = uhci_debug_open, | 483 | .open = uhci_debug_open, |
| 609 | .llseek = uhci_debug_lseek, | 484 | .llseek = uhci_debug_lseek, |
| 610 | .read = uhci_debug_read, | 485 | .read = uhci_debug_read, |
| 611 | .release = uhci_debug_release, | 486 | .release = uhci_debug_release, |
| 612 | }; | 487 | }; |
| 613 | 488 | ||
| 614 | #else /* CONFIG_DEBUG_FS */ | 489 | #endif /* CONFIG_DEBUG_FS */ |
| 615 | 490 | ||
| 616 | #define uhci_debug_operations (* (struct file_operations *) NULL) | 491 | #else /* DEBUG */ |
| 492 | |||
| 493 | static inline void lprintk(char *buf) | ||
| 494 | {} | ||
| 495 | |||
| 496 | static inline int uhci_show_qh(struct uhci_qh *qh, char *buf, | ||
| 497 | int len, int space) | ||
| 498 | { | ||
| 499 | return 0; | ||
| 500 | } | ||
| 501 | |||
| 502 | static inline int uhci_sprint_schedule(struct uhci_hcd *uhci, | ||
| 503 | char *buf, int len) | ||
| 504 | { | ||
| 505 | return 0; | ||
| 506 | } | ||
| 617 | 507 | ||
| 618 | #endif | 508 | #endif |
