提交 4de7d2c2 编写于 作者: A Alan Stern 提交者: Greg Kroah-Hartman

[PATCH] USB: UHCI: store the endpoint type in the QH structure

This patch (as675) simplifies uhci-hcd slightly by storing each endpoint's
type in the corresponding Queue Header structure.
Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 2d61bde7
...@@ -98,6 +98,7 @@ static int uhci_show_urbp(struct urb_priv *urbp, char *buf, int len, int space) ...@@ -98,6 +98,7 @@ static int uhci_show_urbp(struct urb_priv *urbp, char *buf, int len, int space)
char *out = buf; char *out = buf;
struct uhci_td *td; struct uhci_td *td;
int i, nactive, ninactive; int i, nactive, ninactive;
char *ptype;
if (len < 200) if (len < 200)
return 0; return 0;
...@@ -110,13 +111,14 @@ static int uhci_show_urbp(struct urb_priv *urbp, char *buf, int len, int space) ...@@ -110,13 +111,14 @@ static int uhci_show_urbp(struct urb_priv *urbp, char *buf, int len, int space)
(usb_pipein(urbp->urb->pipe) ? "IN" : "OUT")); (usb_pipein(urbp->urb->pipe) ? "IN" : "OUT"));
switch (usb_pipetype(urbp->urb->pipe)) { switch (usb_pipetype(urbp->urb->pipe)) {
case PIPE_ISOCHRONOUS: out += sprintf(out, "ISO"); break; case PIPE_ISOCHRONOUS: ptype = "ISO"; break;
case PIPE_INTERRUPT: out += sprintf(out, "INT"); break; case PIPE_INTERRUPT: ptype = "INT"; break;
case PIPE_BULK: out += sprintf(out, "BLK"); break; case PIPE_BULK: ptype = "BLK"; break;
case PIPE_CONTROL: out += sprintf(out, "CTL"); break; default:
case PIPE_CONTROL: ptype = "CTL"; break;
} }
out += sprintf(out, "%s", (urbp->fsbr ? " FSBR" : "")); out += sprintf(out, "%s%s", ptype, (urbp->fsbr ? " FSBR" : ""));
if (urbp->urb->status != -EINPROGRESS) if (urbp->urb->status != -EINPROGRESS)
out += sprintf(out, " Status=%d", urbp->urb->status); out += sprintf(out, " Status=%d", urbp->urb->status);
...@@ -147,13 +149,23 @@ static int uhci_show_qh(struct uhci_qh *qh, char *buf, int len, int space) ...@@ -147,13 +149,23 @@ static int uhci_show_qh(struct uhci_qh *qh, char *buf, int len, int space)
char *out = buf; char *out = buf;
int i, nurbs; int i, nurbs;
__le32 element = qh_element(qh); __le32 element = qh_element(qh);
char *qtype;
/* Try to make sure there's enough memory */ /* Try to make sure there's enough memory */
if (len < 80 * 6) if (len < 80 * 6)
return 0; return 0;
out += sprintf(out, "%*s[%p] link (%08x) element (%08x)\n", space, "", switch (qh->type) {
qh, le32_to_cpu(qh->link), le32_to_cpu(element)); case USB_ENDPOINT_XFER_ISOC: qtype = "ISO"; break;
case USB_ENDPOINT_XFER_INT: qtype = "INT"; break;
case USB_ENDPOINT_XFER_BULK: qtype = "BLK"; break;
case USB_ENDPOINT_XFER_CONTROL: qtype = "CTL"; break;
default: qtype = "Skel" ; break;
}
out += sprintf(out, "%*s[%p] %s QH link (%08x) element (%08x)\n",
space, "", qh, qtype,
le32_to_cpu(qh->link), le32_to_cpu(element));
if (element & UHCI_PTR_QH) if (element & UHCI_PTR_QH)
out += sprintf(out, "%*s Element points to QH (bug?)\n", space, ""); out += sprintf(out, "%*s Element points to QH (bug?)\n", space, "");
......
...@@ -132,6 +132,7 @@ struct uhci_qh { ...@@ -132,6 +132,7 @@ struct uhci_qh {
unsigned int unlink_frame; /* When the QH was unlinked */ unsigned int unlink_frame; /* When the QH was unlinked */
int state; /* QH_STATE_xxx; see above */ int state; /* QH_STATE_xxx; see above */
int type; /* Queue type (control, bulk, etc) */
unsigned int initial_toggle:1; /* Endpoint's current toggle value */ unsigned int initial_toggle:1; /* Endpoint's current toggle value */
unsigned int needs_fixup:1; /* Must fix the TD toggle values */ unsigned int needs_fixup:1; /* Must fix the TD toggle values */
......
...@@ -179,10 +179,12 @@ static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci, ...@@ -179,10 +179,12 @@ static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci,
qh->hep = hep; qh->hep = hep;
qh->udev = udev; qh->udev = udev;
hep->hcpriv = qh; hep->hcpriv = qh;
qh->type = hep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
} else { /* Skeleton QH */ } else { /* Skeleton QH */
qh->state = QH_STATE_ACTIVE; qh->state = QH_STATE_ACTIVE;
qh->udev = NULL; qh->udev = NULL;
qh->type = -1;
} }
return qh; return qh;
} }
...@@ -217,8 +219,8 @@ static void uhci_save_toggle(struct uhci_qh *qh, struct urb *urb) ...@@ -217,8 +219,8 @@ static void uhci_save_toggle(struct uhci_qh *qh, struct urb *urb)
qh->element = UHCI_PTR_TERM; qh->element = UHCI_PTR_TERM;
/* Only bulk and interrupt pipes have to worry about toggles */ /* Only bulk and interrupt pipes have to worry about toggles */
if (!(usb_pipetype(urb->pipe) == PIPE_BULK || if (!(qh->type == USB_ENDPOINT_XFER_BULK ||
usb_pipetype(urb->pipe) == PIPE_INTERRUPT)) qh->type == USB_ENDPOINT_XFER_INT))
return; return;
/* Find the first active TD; that's the device's toggle state */ /* Find the first active TD; that's the device's toggle state */
...@@ -1099,14 +1101,14 @@ static int uhci_urb_enqueue(struct usb_hcd *hcd, ...@@ -1099,14 +1101,14 @@ static int uhci_urb_enqueue(struct usb_hcd *hcd,
} }
urbp->qh = qh; urbp->qh = qh;
switch (usb_pipetype(urb->pipe)) { switch (qh->type) {
case PIPE_CONTROL: case USB_ENDPOINT_XFER_CONTROL:
ret = uhci_submit_control(uhci, urb, qh); ret = uhci_submit_control(uhci, urb, qh);
break; break;
case PIPE_BULK: case USB_ENDPOINT_XFER_BULK:
ret = uhci_submit_bulk(uhci, urb, qh); ret = uhci_submit_bulk(uhci, urb, qh);
break; break;
case PIPE_INTERRUPT: case USB_ENDPOINT_XFER_INT:
if (list_empty(&qh->queue)) { if (list_empty(&qh->queue)) {
bustime = usb_check_bandwidth(urb->dev, urb); bustime = usb_check_bandwidth(urb->dev, urb);
if (bustime < 0) if (bustime < 0)
...@@ -1125,7 +1127,7 @@ static int uhci_urb_enqueue(struct usb_hcd *hcd, ...@@ -1125,7 +1127,7 @@ static int uhci_urb_enqueue(struct usb_hcd *hcd,
ret = uhci_submit_interrupt(uhci, urb, qh); ret = uhci_submit_interrupt(uhci, urb, qh);
} }
break; break;
case PIPE_ISOCHRONOUS: case USB_ENDPOINT_XFER_ISOC:
bustime = usb_check_bandwidth(urb->dev, urb); bustime = usb_check_bandwidth(urb->dev, urb);
if (bustime < 0) { if (bustime < 0) {
ret = bustime; ret = bustime;
...@@ -1175,7 +1177,7 @@ static int uhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb) ...@@ -1175,7 +1177,7 @@ static int uhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb)
goto done; goto done;
/* Remove Isochronous TDs from the frame list ASAP */ /* Remove Isochronous TDs from the frame list ASAP */
if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) if (urbp->qh->type == USB_ENDPOINT_XFER_ISOC)
uhci_unlink_isochronous_tds(uhci, urb); uhci_unlink_isochronous_tds(uhci, urb);
uhci_unlink_qh(uhci, urbp->qh); uhci_unlink_qh(uhci, urbp->qh);
...@@ -1195,7 +1197,7 @@ __acquires(uhci->lock) ...@@ -1195,7 +1197,7 @@ __acquires(uhci->lock)
struct urb_priv *urbp = (struct urb_priv *) urb->hcpriv; struct urb_priv *urbp = (struct urb_priv *) urb->hcpriv;
/* Isochronous TDs get unlinked directly from the frame list */ /* Isochronous TDs get unlinked directly from the frame list */
if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) if (qh->type == USB_ENDPOINT_XFER_ISOC)
uhci_unlink_isochronous_tds(uhci, urb); uhci_unlink_isochronous_tds(uhci, urb);
/* If the URB isn't first on its queue, adjust the link pointer /* If the URB isn't first on its queue, adjust the link pointer
...@@ -1224,13 +1226,13 @@ __acquires(uhci->lock) ...@@ -1224,13 +1226,13 @@ __acquires(uhci->lock)
uhci_dec_fsbr(uhci, urb); /* Safe since it checks */ uhci_dec_fsbr(uhci, urb); /* Safe since it checks */
uhci_free_urb_priv(uhci, urbp); uhci_free_urb_priv(uhci, urbp);
switch (usb_pipetype(urb->pipe)) { switch (qh->type) {
case PIPE_ISOCHRONOUS: case USB_ENDPOINT_XFER_ISOC:
/* Release bandwidth for Interrupt or Isoc. transfers */ /* Release bandwidth for Interrupt or Isoc. transfers */
if (urb->bandwidth) if (urb->bandwidth)
usb_release_bandwidth(urb->dev, urb, 1); usb_release_bandwidth(urb->dev, urb, 1);
break; break;
case PIPE_INTERRUPT: case USB_ENDPOINT_XFER_INT:
/* Release bandwidth for Interrupt or Isoc. transfers */ /* Release bandwidth for Interrupt or Isoc. transfers */
/* Make sure we don't release if we have a queued URB */ /* Make sure we don't release if we have a queued URB */
if (list_empty(&qh->queue) && urb->bandwidth) if (list_empty(&qh->queue) && urb->bandwidth)
...@@ -1273,14 +1275,14 @@ static void uhci_scan_qh(struct uhci_hcd *uhci, struct uhci_qh *qh, ...@@ -1273,14 +1275,14 @@ static void uhci_scan_qh(struct uhci_hcd *uhci, struct uhci_qh *qh,
urbp = list_entry(qh->queue.next, struct urb_priv, node); urbp = list_entry(qh->queue.next, struct urb_priv, node);
urb = urbp->urb; urb = urbp->urb;
switch (usb_pipetype(urb->pipe)) { switch (qh->type) {
case PIPE_CONTROL: case USB_ENDPOINT_XFER_CONTROL:
status = uhci_result_control(uhci, urb); status = uhci_result_control(uhci, urb);
break; break;
case PIPE_ISOCHRONOUS: case USB_ENDPOINT_XFER_ISOC:
status = uhci_result_isochronous(uhci, urb); status = uhci_result_isochronous(uhci, urb);
break; break;
default: /* PIPE_BULK or PIPE_INTERRUPT */ default: /* USB_ENDPOINT_XFER_BULK or _INT */
status = uhci_result_common(uhci, urb); status = uhci_result_common(uhci, urb);
break; break;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册