aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2007-08-21 15:39:21 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-10-12 17:55:19 -0400
commitb0d9efba3ec53468984aecef8eeaf079089f2e5a (patch)
treea372d053daddc5ff041949b80bab347317a76938 /drivers
parentee7d1f3f0c32d8abe9627aa73dc62ee5bf2daf7f (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')
-rw-r--r--drivers/usb/core/hcd.c9
-rw-r--r--drivers/usb/gadget/dummy_hcd.c9
-rw-r--r--drivers/usb/host/ehci-q.c7
-rw-r--r--drivers/usb/host/isp116x-hcd.c8
-rw-r--r--drivers/usb/host/ohci-q.c11
-rw-r--r--drivers/usb/host/r8a66597-hcd.c7
-rw-r--r--drivers/usb/host/sl811-hcd.c14
-rw-r--r--drivers/usb/host/u132-hcd.c5
-rw-r--r--drivers/usb/host/uhci-q.c8
9 files changed, 18 insertions, 60 deletions
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index a853f63b9254..22a098b318c0 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -366,6 +366,7 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb)
366 spin_unlock_irq(&hcd_root_hub_lock); 366 spin_unlock_irq(&hcd_root_hub_lock);
367 if (status) 367 if (status)
368 return status; 368 return status;
369 urb->hcpriv = hcd; /* Indicate it's queued */
369 370
370 cmd = (struct usb_ctrlrequest *) urb->setup_packet; 371 cmd = (struct usb_ctrlrequest *) urb->setup_packet;
371 typeReq = (cmd->bRequestType << 8) | cmd->bRequest; 372 typeReq = (cmd->bRequestType << 8) | cmd->bRequest;
@@ -579,7 +580,6 @@ void usb_hcd_poll_rh_status(struct usb_hcd *hcd)
579 hcd->poll_pending = 0; 580 hcd->poll_pending = 0;
580 hcd->status_urb = NULL; 581 hcd->status_urb = NULL;
581 urb->status = 0; 582 urb->status = 0;
582 urb->hcpriv = NULL;
583 urb->actual_length = length; 583 urb->actual_length = length;
584 memcpy(urb->transfer_buffer, buffer, length); 584 memcpy(urb->transfer_buffer, buffer, length);
585 585
@@ -675,7 +675,6 @@ static int usb_rh_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
675 del_timer (&hcd->rh_timer); 675 del_timer (&hcd->rh_timer);
676 if (urb == hcd->status_urb) { 676 if (urb == hcd->status_urb) {
677 hcd->status_urb = NULL; 677 hcd->status_urb = NULL;
678 urb->hcpriv = NULL;
679 usb_hcd_unlink_urb_from_ep(hcd, urb); 678 usb_hcd_unlink_urb_from_ep(hcd, urb);
680 679
681 spin_unlock(&hcd_root_hub_lock); 680 spin_unlock(&hcd_root_hub_lock);
@@ -1192,6 +1191,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
1192 if (unlikely(status)) { 1191 if (unlikely(status)) {
1193 usbmon_urb_submit_error(&hcd->self, urb, status); 1192 usbmon_urb_submit_error(&hcd->self, urb, status);
1194 unmap_urb_for_dma(hcd, urb); 1193 unmap_urb_for_dma(hcd, urb);
1194 urb->hcpriv = NULL;
1195 INIT_LIST_HEAD(&urb->urb_list); 1195 INIT_LIST_HEAD(&urb->urb_list);
1196 atomic_dec(&urb->use_count); 1196 atomic_dec(&urb->use_count);
1197 if (urb->reject) 1197 if (urb->reject)
@@ -1265,6 +1265,11 @@ void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb)
1265 unmap_urb_for_dma(hcd, urb); 1265 unmap_urb_for_dma(hcd, urb);
1266 usbmon_urb_complete (&hcd->self, urb); 1266 usbmon_urb_complete (&hcd->self, urb);
1267 usb_unanchor_urb(urb); 1267 usb_unanchor_urb(urb);
1268 urb->hcpriv = NULL;
1269 if (unlikely((urb->transfer_flags & URB_SHORT_NOT_OK) &&
1270 urb->actual_length < urb->transfer_buffer_length &&
1271 !urb->status))
1272 urb->status = -EREMOTEIO;
1268 1273
1269 /* pass ownership to the completion handler */ 1274 /* pass ownership to the completion handler */
1270 urb->complete (urb); 1275 urb->complete (urb);
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index c441d10c087e..0cb032526ca2 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -1099,8 +1099,7 @@ top:
1099 * 1099 *
1100 * partially filling a buffer optionally blocks queue advances 1100 * partially filling a buffer optionally blocks queue advances
1101 * (so completion handlers can clean up the queue) but we don't 1101 * (so completion handlers can clean up the queue) but we don't
1102 * need to emulate such data-in-flight. so we only show part 1102 * need to emulate such data-in-flight.
1103 * of the URB_SHORT_NOT_OK effect: completion status.
1104 */ 1103 */
1105 if (is_short) { 1104 if (is_short) {
1106 if (host_len == dev_len) { 1105 if (host_len == dev_len) {
@@ -1111,10 +1110,7 @@ top:
1111 if (dev_len > host_len) 1110 if (dev_len > host_len)
1112 maybe_set_status (urb, -EOVERFLOW); 1111 maybe_set_status (urb, -EOVERFLOW);
1113 else 1112 else
1114 maybe_set_status (urb, 1113 maybe_set_status (urb, 0);
1115 (urb->transfer_flags
1116 & URB_SHORT_NOT_OK)
1117 ? -EREMOTEIO : 0);
1118 } else if (!to_host) { 1114 } else if (!to_host) {
1119 maybe_set_status (urb, 0); 1115 maybe_set_status (urb, 0);
1120 if (host_len > dev_len) 1116 if (host_len > dev_len)
@@ -1516,7 +1512,6 @@ restart:
1516 continue; 1512 continue;
1517 1513
1518return_urb: 1514return_urb:
1519 urb->hcpriv = NULL;
1520 list_del (&urbp->urbp_list); 1515 list_del (&urbp->urbp_list);
1521 kfree (urbp); 1516 kfree (urbp);
1522 if (ep) 1517 if (ep)
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,