diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2007-08-21 15:39:21 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-10-12 17:55:19 -0400 |
commit | b0d9efba3ec53468984aecef8eeaf079089f2e5a (patch) | |
tree | a372d053daddc5ff041949b80bab347317a76938 /drivers/usb/host | |
parent | ee7d1f3f0c32d8abe9627aa73dc62ee5bf2daf7f (diff) |
USB: centralize -EREMOTEIO handling
This patch (as969) continues the ongoing changes to the way HCDs
report URB statuses. The programming interface has been simplified by
making usbcore responsible for clearing urb->hcpriv and for setting
-EREMOTEIO status when an URB with the URB_SHORT_NOT_OK flag ends up
as a short transfer.
By moving the work out of the HCDs, this removes a fair amount of
repeated code.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: David Brownell <david-b@pacbell.net>
CC: Olav Kongas <ok@artecdesign.ee>
CC: Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
CC: Tony Olech <tony.olech@elandigitalsystems.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r-- | drivers/usb/host/ehci-q.c | 7 | ||||
-rw-r--r-- | drivers/usb/host/isp116x-hcd.c | 8 | ||||
-rw-r--r-- | drivers/usb/host/ohci-q.c | 11 | ||||
-rw-r--r-- | drivers/usb/host/r8a66597-hcd.c | 7 | ||||
-rw-r--r-- | drivers/usb/host/sl811-hcd.c | 14 | ||||
-rw-r--r-- | drivers/usb/host/u132-hcd.c | 5 | ||||
-rw-r--r-- | drivers/usb/host/uhci-q.c | 8 |
7 files changed, 9 insertions, 51 deletions
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index 1da2de4d34ed..e80b5c417d74 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c | |||
@@ -232,7 +232,6 @@ __acquires(ehci->lock) | |||
232 | } | 232 | } |
233 | 233 | ||
234 | spin_lock (&urb->lock); | 234 | spin_lock (&urb->lock); |
235 | urb->hcpriv = NULL; | ||
236 | switch (urb->status) { | 235 | switch (urb->status) { |
237 | case -EINPROGRESS: /* success */ | 236 | case -EINPROGRESS: /* success */ |
238 | urb->status = 0; | 237 | urb->status = 0; |
@@ -395,8 +394,10 @@ halt: | |||
395 | /* remove it from the queue */ | 394 | /* remove it from the queue */ |
396 | spin_lock (&urb->lock); | 395 | spin_lock (&urb->lock); |
397 | qtd_copy_status (ehci, urb, qtd->length, token); | 396 | qtd_copy_status (ehci, urb, qtd->length, token); |
398 | do_status = (urb->status == -EREMOTEIO) | 397 | if (unlikely(urb->status == -EREMOTEIO)) { |
399 | && usb_pipecontrol (urb->pipe); | 398 | do_status = usb_pipecontrol(urb->pipe); |
399 | urb->status = 0; | ||
400 | } | ||
400 | spin_unlock (&urb->lock); | 401 | spin_unlock (&urb->lock); |
401 | 402 | ||
402 | if (stopped && qtd->qtd_list.prev != &qh->qtd_list) { | 403 | if (stopped && qtd->qtd_list.prev != &qh->qtd_list) { |
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index f2b5d6281c5d..c2919dbc3f54 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c | |||
@@ -282,7 +282,6 @@ __releases(isp116x->lock) __acquires(isp116x->lock) | |||
282 | { | 282 | { |
283 | unsigned i; | 283 | unsigned i; |
284 | 284 | ||
285 | urb->hcpriv = NULL; | ||
286 | ep->error_count = 0; | 285 | ep->error_count = 0; |
287 | 286 | ||
288 | if (usb_pipecontrol(urb->pipe)) | 287 | if (usb_pipecontrol(urb->pipe)) |
@@ -446,12 +445,7 @@ static void postproc_atl_queue(struct isp116x *isp116x) | |||
446 | if (PTD_GET_ACTIVE(ptd) | 445 | if (PTD_GET_ACTIVE(ptd) |
447 | || (cc != TD_CC_NOERROR && cc < 0x0E)) | 446 | || (cc != TD_CC_NOERROR && cc < 0x0E)) |
448 | break; | 447 | break; |
449 | if ((urb->transfer_flags & URB_SHORT_NOT_OK) && | 448 | status = 0; |
450 | urb->actual_length < | ||
451 | urb->transfer_buffer_length) | ||
452 | status = -EREMOTEIO; | ||
453 | else | ||
454 | status = 0; | ||
455 | ep->nextpid = 0; | 449 | ep->nextpid = 0; |
456 | break; | 450 | break; |
457 | default: | 451 | default: |
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c index 889c0720743b..8aad6199cdcc 100644 --- a/drivers/usb/host/ohci-q.c +++ b/drivers/usb/host/ohci-q.c | |||
@@ -43,21 +43,10 @@ __acquires(ohci->lock) | |||
43 | // ASSERT (urb->hcpriv != 0); | 43 | // ASSERT (urb->hcpriv != 0); |
44 | 44 | ||
45 | urb_free_priv (ohci, urb->hcpriv); | 45 | urb_free_priv (ohci, urb->hcpriv); |
46 | urb->hcpriv = NULL; | ||
47 | 46 | ||
48 | spin_lock (&urb->lock); | 47 | spin_lock (&urb->lock); |
49 | if (likely (urb->status == -EINPROGRESS)) | 48 | if (likely (urb->status == -EINPROGRESS)) |
50 | urb->status = 0; | 49 | urb->status = 0; |
51 | /* report short control reads right even though the data TD always | ||
52 | * has TD_R set. (much simpler, but creates the 1-td limit.) | ||
53 | */ | ||
54 | if (unlikely (urb->transfer_flags & URB_SHORT_NOT_OK) | ||
55 | && unlikely (usb_pipecontrol (urb->pipe)) | ||
56 | && urb->actual_length < urb->transfer_buffer_length | ||
57 | && usb_pipein (urb->pipe) | ||
58 | && urb->status == 0) { | ||
59 | urb->status = -EREMOTEIO; | ||
60 | } | ||
61 | spin_unlock (&urb->lock); | 50 | spin_unlock (&urb->lock); |
62 | 51 | ||
63 | switch (usb_pipetype (urb->pipe)) { | 52 | switch (usb_pipetype (urb->pipe)) { |
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index 49cf998c172a..60248b01ce14 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c | |||
@@ -783,7 +783,6 @@ static void force_dequeue(struct r8a66597 *r8a66597, u16 pipenum, u16 address) | |||
783 | 783 | ||
784 | if (urb) { | 784 | if (urb) { |
785 | urb->status = -ENODEV; | 785 | urb->status = -ENODEV; |
786 | urb->hcpriv = NULL; | ||
787 | usb_hcd_unlink_urb_from_ep(r8a66597_to_hcd(r8a66597), | 786 | usb_hcd_unlink_urb_from_ep(r8a66597_to_hcd(r8a66597), |
788 | urb); | 787 | urb); |
789 | 788 | ||
@@ -1134,7 +1133,6 @@ __releases(r8a66597->lock) __acquires(r8a66597->lock) | |||
1134 | if (usb_pipeisoc(urb->pipe)) | 1133 | if (usb_pipeisoc(urb->pipe)) |
1135 | urb->start_frame = r8a66597_get_frame(hcd); | 1134 | urb->start_frame = r8a66597_get_frame(hcd); |
1136 | 1135 | ||
1137 | urb->hcpriv = NULL; | ||
1138 | usb_hcd_unlink_urb_from_ep(r8a66597_to_hcd(r8a66597), urb); | 1136 | usb_hcd_unlink_urb_from_ep(r8a66597_to_hcd(r8a66597), urb); |
1139 | 1137 | ||
1140 | spin_unlock(&r8a66597->lock); | 1138 | spin_unlock(&r8a66597->lock); |
@@ -1202,9 +1200,6 @@ static void packet_read(struct r8a66597 *r8a66597, u16 pipenum) | |||
1202 | td->zero_packet = 1; | 1200 | td->zero_packet = 1; |
1203 | if (rcv_len < bufsize) { | 1201 | if (rcv_len < bufsize) { |
1204 | td->short_packet = 1; | 1202 | td->short_packet = 1; |
1205 | if (urb->transfer_buffer_length != urb->actual_length && | ||
1206 | urb->transfer_flags & URB_SHORT_NOT_OK) | ||
1207 | status = -EREMOTEIO; | ||
1208 | } | 1203 | } |
1209 | if (usb_pipeisoc(urb->pipe)) { | 1204 | if (usb_pipeisoc(urb->pipe)) { |
1210 | urb->iso_frame_desc[td->iso_cnt].actual_length = size; | 1205 | urb->iso_frame_desc[td->iso_cnt].actual_length = size; |
@@ -1214,7 +1209,7 @@ static void packet_read(struct r8a66597 *r8a66597, u16 pipenum) | |||
1214 | } | 1209 | } |
1215 | 1210 | ||
1216 | /* check transfer finish */ | 1211 | /* check transfer finish */ |
1217 | if (check_transfer_finish(td, urb)) { | 1212 | if (finish || check_transfer_finish(td, urb)) { |
1218 | pipe_stop(r8a66597, td->pipe); | 1213 | pipe_stop(r8a66597, td->pipe); |
1219 | pipe_irq_disable(r8a66597, pipenum); | 1214 | pipe_irq_disable(r8a66597, pipenum); |
1220 | finish = 1; | 1215 | finish = 1; |
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index 15a93f946afd..e90953a9c9fb 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c | |||
@@ -438,7 +438,6 @@ static void finish_request( | |||
438 | spin_lock(&urb->lock); | 438 | spin_lock(&urb->lock); |
439 | if (urb->status == -EINPROGRESS) | 439 | if (urb->status == -EINPROGRESS) |
440 | urb->status = status; | 440 | urb->status = status; |
441 | urb->hcpriv = NULL; | ||
442 | spin_unlock(&urb->lock); | 441 | spin_unlock(&urb->lock); |
443 | 442 | ||
444 | usb_hcd_unlink_urb_from_ep(sl811_to_hcd(sl811), urb); | 443 | usb_hcd_unlink_urb_from_ep(sl811_to_hcd(sl811), urb); |
@@ -545,17 +544,10 @@ done(struct sl811 *sl811, struct sl811h_ep *ep, u8 bank) | |||
545 | sl811_read_buf(sl811, SL811HS_PACKET_BUF(bank == 0), | 544 | sl811_read_buf(sl811, SL811HS_PACKET_BUF(bank == 0), |
546 | buf, len); | 545 | buf, len); |
547 | usb_dotoggle(udev, ep->epnum, 0); | 546 | usb_dotoggle(udev, ep->epnum, 0); |
548 | if (urb->actual_length == urb->transfer_buffer_length) | 547 | if (urb->actual_length == urb->transfer_buffer_length |
548 | || len < ep->maxpacket) | ||
549 | urbstat = 0; | 549 | urbstat = 0; |
550 | else if (len < ep->maxpacket) { | 550 | if (usb_pipecontrol(urb->pipe) && urbstat == 0) { |
551 | if (urb->transfer_flags & URB_SHORT_NOT_OK) | ||
552 | urbstat = -EREMOTEIO; | ||
553 | else | ||
554 | urbstat = 0; | ||
555 | } | ||
556 | if (usb_pipecontrol(urb->pipe) | ||
557 | && (urbstat == -EREMOTEIO | ||
558 | || urbstat == 0)) { | ||
559 | 551 | ||
560 | /* NOTE if the status stage STALLs (why?), | 552 | /* NOTE if the status stage STALLs (why?), |
561 | * this reports the wrong urb status. | 553 | * this reports the wrong urb status. |
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c index c87660b5edc3..1381275d448f 100644 --- a/drivers/usb/host/u132-hcd.c +++ b/drivers/usb/host/u132-hcd.c | |||
@@ -519,7 +519,6 @@ static void u132_hcd_giveback_urb(struct u132 *u132, struct u132_endp *endp, | |||
519 | struct usb_hcd *hcd = u132_to_hcd(u132); | 519 | struct usb_hcd *hcd = u132_to_hcd(u132); |
520 | urb->error_count = 0; | 520 | urb->error_count = 0; |
521 | urb->status = status; | 521 | urb->status = status; |
522 | urb->hcpriv = NULL; | ||
523 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | 522 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); |
524 | usb_hcd_unlink_urb_from_ep(hcd, urb); | 523 | usb_hcd_unlink_urb_from_ep(hcd, urb); |
525 | endp->queue_next += 1; | 524 | endp->queue_next += 1; |
@@ -560,7 +559,6 @@ static void u132_hcd_abandon_urb(struct u132 *u132, struct u132_endp *endp, | |||
560 | struct usb_hcd *hcd = u132_to_hcd(u132); | 559 | struct usb_hcd *hcd = u132_to_hcd(u132); |
561 | urb->error_count = 0; | 560 | urb->error_count = 0; |
562 | urb->status = status; | 561 | urb->status = status; |
563 | urb->hcpriv = NULL; | ||
564 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | 562 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); |
565 | usb_hcd_unlink_urb_from_ep(hcd, urb); | 563 | usb_hcd_unlink_urb_from_ep(hcd, urb); |
566 | endp->queue_next += 1; | 564 | endp->queue_next += 1; |
@@ -2430,7 +2428,6 @@ static int dequeue_from_overflow_chain(struct u132 *u132, | |||
2430 | list_del(scan); | 2428 | list_del(scan); |
2431 | endp->queue_size -= 1; | 2429 | endp->queue_size -= 1; |
2432 | urb->error_count = 0; | 2430 | urb->error_count = 0; |
2433 | urb->hcpriv = NULL; | ||
2434 | usb_hcd_giveback_urb(hcd, urb); | 2431 | usb_hcd_giveback_urb(hcd, urb); |
2435 | return 0; | 2432 | return 0; |
2436 | } else | 2433 | } else |
@@ -2472,7 +2469,6 @@ static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp, | |||
2472 | endp->edset_flush = 1; | 2469 | endp->edset_flush = 1; |
2473 | u132_endp_queue_work(u132, endp, 0); | 2470 | u132_endp_queue_work(u132, endp, 0); |
2474 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 2471 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
2475 | urb->hcpriv = NULL; | ||
2476 | return 0; | 2472 | return 0; |
2477 | } else { | 2473 | } else { |
2478 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 2474 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
@@ -2517,7 +2513,6 @@ static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp, | |||
2517 | irqs); | 2513 | irqs); |
2518 | kfree(urbq); | 2514 | kfree(urbq); |
2519 | } urb->error_count = 0; | 2515 | } urb->error_count = 0; |
2520 | urb->hcpriv = NULL; | ||
2521 | usb_hcd_giveback_urb(hcd, urb); | 2516 | usb_hcd_giveback_urb(hcd, urb); |
2522 | return 0; | 2517 | return 0; |
2523 | } else if (list_empty(&endp->urb_more)) { | 2518 | } else if (list_empty(&endp->urb_more)) { |
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c index 793a04685ef4..fbc3af392c26 100644 --- a/drivers/usb/host/uhci-q.c +++ b/drivers/usb/host/uhci-q.c | |||
@@ -757,7 +757,6 @@ static void uhci_free_urb_priv(struct uhci_hcd *uhci, | |||
757 | uhci_free_td(uhci, td); | 757 | uhci_free_td(uhci, td); |
758 | } | 758 | } |
759 | 759 | ||
760 | urbp->urb->hcpriv = NULL; | ||
761 | kmem_cache_free(uhci_up_cachep, urbp); | 760 | kmem_cache_free(uhci_up_cachep, urbp); |
762 | } | 761 | } |
763 | 762 | ||
@@ -1494,13 +1493,6 @@ __acquires(uhci->lock) | |||
1494 | * unlinked first. Regardless, don't confuse people with a | 1493 | * unlinked first. Regardless, don't confuse people with a |
1495 | * negative length. */ | 1494 | * negative length. */ |
1496 | urb->actual_length = max(urb->actual_length, 0); | 1495 | urb->actual_length = max(urb->actual_length, 0); |
1497 | |||
1498 | /* Report erroneous short transfers */ | ||
1499 | if (unlikely((urb->transfer_flags & URB_SHORT_NOT_OK) && | ||
1500 | urb->actual_length < | ||
1501 | urb->transfer_buffer_length && | ||
1502 | urb->status == 0)) | ||
1503 | urb->status = -EREMOTEIO; | ||
1504 | } | 1496 | } |
1505 | 1497 | ||
1506 | /* When giving back the first URB in an Isochronous queue, | 1498 | /* When giving back the first URB in an Isochronous queue, |