Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 61935
b: refs/heads/master
c: e7e7c36
h: refs/heads/master
i:
  61933: 8e4d19e
  61931: c02b474
  61927: 6ad6e37
  61919: 4f84390
v: v3
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Jul 20, 2007
1 parent 39e768d commit eb4def7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e94fa28f137813c2f6e05470b41bd8f3c5422a04
refs/heads/master: e7e7c360fb07020b24652843aec442325baad0ce
59 changes: 38 additions & 21 deletions trunk/drivers/usb/host/uhci-q.c
Original file line number Diff line number Diff line change
Expand Up @@ -827,8 +827,10 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb,
* If direction is "send", change the packet ID from SETUP (0x2D)
* to OUT (0xE1). Else change it from SETUP to IN (0x69) and
* set Short Packet Detect (SPD) for all data packets.
*
* 0-length transfers always get treated as "send".
*/
if (usb_pipeout(urb->pipe))
if (usb_pipeout(urb->pipe) || len == 0)
destination ^= (USB_PID_SETUP ^ USB_PID_OUT);
else {
destination ^= (USB_PID_SETUP ^ USB_PID_IN);
Expand All @@ -839,7 +841,12 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb,
* Build the DATA TDs
*/
while (len > 0) {
int pktsze = min(len, maxsze);
int pktsze = maxsze;

if (len <= pktsze) { /* The last data packet */
pktsze = len;
status &= ~TD_CTRL_SPD;
}

td = uhci_alloc_td(uhci);
if (!td)
Expand All @@ -866,20 +873,10 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb,
goto nomem;
*plink = LINK_TO_TD(td);

/*
* It's IN if the pipe is an output pipe or we're not expecting
* data back.
*/
destination &= ~TD_TOKEN_PID_MASK;
if (usb_pipeout(urb->pipe) || !urb->transfer_buffer_length)
destination |= USB_PID_IN;
else
destination |= USB_PID_OUT;

/* Change direction for the status transaction */
destination ^= (USB_PID_IN ^ USB_PID_OUT);
destination |= TD_TOKEN_TOGGLE; /* End in Data1 */

status &= ~TD_CTRL_SPD;

uhci_add_td_to_urbp(td, urbp);
uhci_fill_td(td, status | TD_CTRL_IOC,
destination | uhci_explen(0), 0);
Expand Down Expand Up @@ -1185,10 +1182,18 @@ static int uhci_result_common(struct uhci_hcd *uhci, struct urb *urb)
}
}

/* Did we receive a short packet? */
} else if (len < uhci_expected_length(td_token(td))) {

/* We received a short packet */
if (urb->transfer_flags & URB_SHORT_NOT_OK)
/* For control transfers, go to the status TD if
* this isn't already the last data TD */
if (qh->type == USB_ENDPOINT_XFER_CONTROL) {
if (td->list.next != urbp->td_list.prev)
ret = 1;
}

/* For bulk and interrupt, this may be an error */
else if (urb->transfer_flags & URB_SHORT_NOT_OK)
ret = -EREMOTEIO;

/* Fixup needed only if this isn't the URB's last TD */
Expand All @@ -1208,10 +1213,6 @@ static int uhci_result_common(struct uhci_hcd *uhci, struct urb *urb)

err:
if (ret < 0) {
/* In case a control transfer gets an error
* during the setup stage */
urb->actual_length = max(urb->actual_length, 0);

/* Note that the queue has stopped and save
* the next toggle value */
qh->element = UHCI_PTR_TERM;
Expand Down Expand Up @@ -1489,9 +1490,25 @@ __acquires(uhci->lock)
{
struct urb_priv *urbp = (struct urb_priv *) urb->hcpriv;

if (qh->type == USB_ENDPOINT_XFER_CONTROL) {

/* urb->actual_length < 0 means the setup transaction didn't
* complete successfully. Either it failed or the URB was
* unlinked first. Regardless, don't confuse people with a
* negative length. */
urb->actual_length = max(urb->actual_length, 0);

/* Report erroneous short transfers */
if (unlikely((urb->transfer_flags & URB_SHORT_NOT_OK) &&
urb->actual_length <
urb->transfer_buffer_length &&
urb->status == 0))
urb->status = -EREMOTEIO;
}

/* When giving back the first URB in an Isochronous queue,
* reinitialize the QH's iso-related members for the next URB. */
if (qh->type == USB_ENDPOINT_XFER_ISOC &&
else if (qh->type == USB_ENDPOINT_XFER_ISOC &&
urbp->node.prev == &qh->queue &&
urbp->node.next != &qh->queue) {
struct urb *nurb = list_entry(urbp->node.next,
Expand Down

0 comments on commit eb4def7

Please sign in to comment.