diff options
Diffstat (limited to 'drivers/usb/host/uhci-q.c')
-rw-r--r-- | drivers/usb/host/uhci-q.c | 94 |
1 files changed, 24 insertions, 70 deletions
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c index f4ebdb3e488f..19a0cc02b9a2 100644 --- a/drivers/usb/host/uhci-q.c +++ b/drivers/usb/host/uhci-q.c | |||
@@ -45,43 +45,27 @@ static inline void uhci_clear_next_interrupt(struct uhci_hcd *uhci) | |||
45 | */ | 45 | */ |
46 | static void uhci_fsbr_on(struct uhci_hcd *uhci) | 46 | static void uhci_fsbr_on(struct uhci_hcd *uhci) |
47 | { | 47 | { |
48 | struct uhci_qh *fsbr_qh, *lqh, *tqh; | 48 | struct uhci_qh *lqh; |
49 | 49 | ||
50 | /* The terminating skeleton QH always points back to the first | ||
51 | * FSBR QH. Make the last async QH point to the terminating | ||
52 | * skeleton QH. */ | ||
50 | uhci->fsbr_is_on = 1; | 53 | uhci->fsbr_is_on = 1; |
51 | lqh = list_entry(uhci->skel_async_qh->node.prev, | 54 | lqh = list_entry(uhci->skel_async_qh->node.prev, |
52 | struct uhci_qh, node); | 55 | struct uhci_qh, node); |
53 | 56 | lqh->link = LINK_TO_QH(uhci->skel_term_qh); | |
54 | /* Find the first FSBR QH. Linear search through the list is | ||
55 | * acceptable because normally FSBR gets turned on as soon as | ||
56 | * one QH needs it. */ | ||
57 | fsbr_qh = NULL; | ||
58 | list_for_each_entry_reverse(tqh, &uhci->skel_async_qh->node, node) { | ||
59 | if (tqh->skel < SKEL_FSBR) | ||
60 | break; | ||
61 | fsbr_qh = tqh; | ||
62 | } | ||
63 | |||
64 | /* No FSBR QH means we must insert the terminating skeleton QH */ | ||
65 | if (!fsbr_qh) { | ||
66 | uhci->skel_term_qh->link = LINK_TO_QH(uhci->skel_term_qh); | ||
67 | wmb(); | ||
68 | lqh->link = uhci->skel_term_qh->link; | ||
69 | |||
70 | /* Otherwise loop the last QH to the first FSBR QH */ | ||
71 | } else | ||
72 | lqh->link = LINK_TO_QH(fsbr_qh); | ||
73 | } | 57 | } |
74 | 58 | ||
75 | static void uhci_fsbr_off(struct uhci_hcd *uhci) | 59 | static void uhci_fsbr_off(struct uhci_hcd *uhci) |
76 | { | 60 | { |
77 | struct uhci_qh *lqh; | 61 | struct uhci_qh *lqh; |
78 | 62 | ||
63 | /* Remove the link from the last async QH to the terminating | ||
64 | * skeleton QH. */ | ||
79 | uhci->fsbr_is_on = 0; | 65 | uhci->fsbr_is_on = 0; |
80 | lqh = list_entry(uhci->skel_async_qh->node.prev, | 66 | lqh = list_entry(uhci->skel_async_qh->node.prev, |
81 | struct uhci_qh, node); | 67 | struct uhci_qh, node); |
82 | 68 | lqh->link = UHCI_PTR_TERM; | |
83 | /* End the async list normally and unlink the terminating QH */ | ||
84 | lqh->link = uhci->skel_term_qh->link = UHCI_PTR_TERM; | ||
85 | } | 69 | } |
86 | 70 | ||
87 | static void uhci_add_fsbr(struct uhci_hcd *uhci, struct urb *urb) | 71 | static void uhci_add_fsbr(struct uhci_hcd *uhci, struct urb *urb) |
@@ -464,9 +448,8 @@ static void link_interrupt(struct uhci_hcd *uhci, struct uhci_qh *qh) | |||
464 | */ | 448 | */ |
465 | static void link_async(struct uhci_hcd *uhci, struct uhci_qh *qh) | 449 | static void link_async(struct uhci_hcd *uhci, struct uhci_qh *qh) |
466 | { | 450 | { |
467 | struct uhci_qh *pqh, *lqh; | 451 | struct uhci_qh *pqh; |
468 | __le32 link_to_new_qh; | 452 | __le32 link_to_new_qh; |
469 | __le32 *extra_link = &link_to_new_qh; | ||
470 | 453 | ||
471 | /* Find the predecessor QH for our new one and insert it in the list. | 454 | /* Find the predecessor QH for our new one and insert it in the list. |
472 | * The list of QHs is expected to be short, so linear search won't | 455 | * The list of QHs is expected to be short, so linear search won't |
@@ -476,31 +459,17 @@ static void link_async(struct uhci_hcd *uhci, struct uhci_qh *qh) | |||
476 | break; | 459 | break; |
477 | } | 460 | } |
478 | list_add(&qh->node, &pqh->node); | 461 | list_add(&qh->node, &pqh->node); |
479 | qh->link = pqh->link; | ||
480 | |||
481 | link_to_new_qh = LINK_TO_QH(qh); | ||
482 | |||
483 | /* If this is now the first FSBR QH, take special action */ | ||
484 | if (uhci->fsbr_is_on && pqh->skel < SKEL_FSBR && | ||
485 | qh->skel >= SKEL_FSBR) { | ||
486 | lqh = list_entry(uhci->skel_async_qh->node.prev, | ||
487 | struct uhci_qh, node); | ||
488 | |||
489 | /* If the new QH is also the last one, we must unlink | ||
490 | * the terminating skeleton QH and make the new QH point | ||
491 | * back to itself. */ | ||
492 | if (qh == lqh) { | ||
493 | qh->link = link_to_new_qh; | ||
494 | extra_link = &uhci->skel_term_qh->link; | ||
495 | |||
496 | /* Otherwise the last QH must point to the new QH */ | ||
497 | } else | ||
498 | extra_link = &lqh->link; | ||
499 | } | ||
500 | 462 | ||
501 | /* Link it into the schedule */ | 463 | /* Link it into the schedule */ |
464 | qh->link = pqh->link; | ||
502 | wmb(); | 465 | wmb(); |
503 | *extra_link = pqh->link = link_to_new_qh; | 466 | link_to_new_qh = LINK_TO_QH(qh); |
467 | pqh->link = link_to_new_qh; | ||
468 | |||
469 | /* If this is now the first FSBR QH, link the terminating skeleton | ||
470 | * QH to it. */ | ||
471 | if (pqh->skel < SKEL_FSBR && qh->skel >= SKEL_FSBR) | ||
472 | uhci->skel_term_qh->link = link_to_new_qh; | ||
504 | } | 473 | } |
505 | 474 | ||
506 | /* | 475 | /* |
@@ -561,31 +530,16 @@ static void unlink_interrupt(struct uhci_hcd *uhci, struct uhci_qh *qh) | |||
561 | */ | 530 | */ |
562 | static void unlink_async(struct uhci_hcd *uhci, struct uhci_qh *qh) | 531 | static void unlink_async(struct uhci_hcd *uhci, struct uhci_qh *qh) |
563 | { | 532 | { |
564 | struct uhci_qh *pqh, *lqh; | 533 | struct uhci_qh *pqh; |
565 | __le32 link_to_next_qh = qh->link; | 534 | __le32 link_to_next_qh = qh->link; |
566 | 535 | ||
567 | pqh = list_entry(qh->node.prev, struct uhci_qh, node); | 536 | pqh = list_entry(qh->node.prev, struct uhci_qh, node); |
568 | |||
569 | /* If this is the first FSBQ QH, take special action */ | ||
570 | if (uhci->fsbr_is_on && pqh->skel < SKEL_FSBR && | ||
571 | qh->skel >= SKEL_FSBR) { | ||
572 | lqh = list_entry(uhci->skel_async_qh->node.prev, | ||
573 | struct uhci_qh, node); | ||
574 | |||
575 | /* If this QH is also the last one, we must link in | ||
576 | * the terminating skeleton QH. */ | ||
577 | if (qh == lqh) { | ||
578 | link_to_next_qh = LINK_TO_QH(uhci->skel_term_qh); | ||
579 | uhci->skel_term_qh->link = link_to_next_qh; | ||
580 | wmb(); | ||
581 | qh->link = link_to_next_qh; | ||
582 | |||
583 | /* Otherwise the last QH must point to the new first FSBR QH */ | ||
584 | } else | ||
585 | lqh->link = link_to_next_qh; | ||
586 | } | ||
587 | |||
588 | pqh->link = link_to_next_qh; | 537 | pqh->link = link_to_next_qh; |
538 | |||
539 | /* If this was the old first FSBR QH, link the terminating skeleton | ||
540 | * QH to the next (new first FSBR) QH. */ | ||
541 | if (pqh->skel < SKEL_FSBR && qh->skel >= SKEL_FSBR) | ||
542 | uhci->skel_term_qh->link = link_to_next_qh; | ||
589 | mb(); | 543 | mb(); |
590 | } | 544 | } |
591 | 545 | ||
@@ -1217,7 +1171,7 @@ static int uhci_result_common(struct uhci_hcd *uhci, struct urb *urb) | |||
1217 | 1171 | ||
1218 | if (debug > 1 && errbuf) { | 1172 | if (debug > 1 && errbuf) { |
1219 | /* Print the chain for debugging */ | 1173 | /* Print the chain for debugging */ |
1220 | uhci_show_qh(urbp->qh, errbuf, | 1174 | uhci_show_qh(uhci, urbp->qh, errbuf, |
1221 | ERRBUF_LEN, 0); | 1175 | ERRBUF_LEN, 0); |
1222 | lprintk(errbuf); | 1176 | lprintk(errbuf); |
1223 | } | 1177 | } |