aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb
diff options
context:
space:
mode:
authorSergei Shtylyov <sshtylyov@ru.mvista.com>2009-03-27 15:58:31 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-06-16 00:44:40 -0400
commitc9cd06b3d6ea825c62e277def929cc4315802b48 (patch)
treed41c1619cf5ca3e3ed38afb971bbabbb2362c884 /drivers/usb/musb
parent81ec4e4a5116c2bccec2dd1d350ceb4372846ba8 (diff)
musb_host: refactor URB giveback
As musb_advance_schedule() is now the only remaning caller of musb_giveback() (and the only valid context of such call), just fold the latter into the former and then rename __musb_giveback() into musb_giveback(). This is a net minor shrink. Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/musb')
-rw-r--r--drivers/usb/musb/musb_host.c54
1 files changed, 20 insertions, 34 deletions
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index e666f609ad7..c1bb192ecbe 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -295,9 +295,8 @@ start:
295 } 295 }
296} 296}
297 297
298/* caller owns controller lock, irqs are blocked */ 298/* Context: caller owns controller lock, IRQs are blocked */
299static void 299static void musb_giveback(struct musb *musb, struct urb *urb, int status)
300__musb_giveback(struct musb *musb, struct urb *urb, int status)
301__releases(musb->lock) 300__releases(musb->lock)
302__acquires(musb->lock) 301__acquires(musb->lock)
303{ 302{
@@ -350,14 +349,22 @@ static inline void musb_save_toggle(struct musb_qh *qh, int is_in,
350 usb_settoggle(urb->dev, qh->epnum, !is_in, csr ? 1 : 0); 349 usb_settoggle(urb->dev, qh->epnum, !is_in, csr ? 1 : 0);
351} 350}
352 351
353/* caller owns controller lock, irqs are blocked */ 352/*
354static struct musb_qh * 353 * Advance this hardware endpoint's queue, completing the specified URB and
355musb_giveback(struct musb_qh *qh, struct urb *urb, int status) 354 * advancing to either the next URB queued to that qh, or else invalidating
355 * that qh and advancing to the next qh scheduled after the current one.
356 *
357 * Context: caller owns controller lock, IRQs are blocked
358 */
359static void musb_advance_schedule(struct musb *musb, struct urb *urb,
360 struct musb_hw_ep *hw_ep, int is_in)
356{ 361{
362 struct musb_qh *qh = musb_ep_get_qh(hw_ep, is_in);
357 struct musb_hw_ep *ep = qh->hw_ep; 363 struct musb_hw_ep *ep = qh->hw_ep;
358 struct musb *musb = ep->musb;
359 int is_in = usb_pipein(urb->pipe);
360 int ready = qh->is_ready; 364 int ready = qh->is_ready;
365 int status;
366
367 status = (urb->status == -EINPROGRESS) ? 0 : urb->status;
361 368
362 /* save toggle eagerly, for paranoia */ 369 /* save toggle eagerly, for paranoia */
363 switch (qh->type) { 370 switch (qh->type) {
@@ -366,13 +373,13 @@ musb_giveback(struct musb_qh *qh, struct urb *urb, int status)
366 musb_save_toggle(qh, is_in, urb); 373 musb_save_toggle(qh, is_in, urb);
367 break; 374 break;
368 case USB_ENDPOINT_XFER_ISOC: 375 case USB_ENDPOINT_XFER_ISOC:
369 if (status == 0 && urb->error_count) 376 if (urb->error_count)
370 status = -EXDEV; 377 status = -EXDEV;
371 break; 378 break;
372 } 379 }
373 380
374 qh->is_ready = 0; 381 qh->is_ready = 0;
375 __musb_giveback(musb, urb, status); 382 musb_giveback(musb, urb, status);
376 qh->is_ready = ready; 383 qh->is_ready = ready;
377 384
378 /* reclaim resources (and bandwidth) ASAP; deschedule it, and 385 /* reclaim resources (and bandwidth) ASAP; deschedule it, and
@@ -416,31 +423,10 @@ musb_giveback(struct musb_qh *qh, struct urb *urb, int status)
416 break; 423 break;
417 } 424 }
418 } 425 }
419 return qh;
420}
421
422/*
423 * Advance this hardware endpoint's queue, completing the specified urb and
424 * advancing to either the next urb queued to that qh, or else invalidating
425 * that qh and advancing to the next qh scheduled after the current one.
426 *
427 * Context: caller owns controller lock, irqs are blocked
428 */
429static void
430musb_advance_schedule(struct musb *musb, struct urb *urb,
431 struct musb_hw_ep *hw_ep, int is_in)
432{
433 struct musb_qh *qh = musb_ep_get_qh(hw_ep, is_in);
434
435 if (urb->status == -EINPROGRESS)
436 qh = musb_giveback(qh, urb, 0);
437 else
438 qh = musb_giveback(qh, urb, urb->status);
439 426
440 if (qh != NULL && qh->is_ready) { 427 if (qh != NULL && qh->is_ready) {
441 DBG(4, "... next ep%d %cX urb %p\n", 428 DBG(4, "... next ep%d %cX urb %p\n",
442 hw_ep->epnum, is_in ? 'R' : 'T', 429 hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh));
443 next_urb(qh));
444 musb_start_urb(musb, is_in, qh); 430 musb_start_urb(musb, is_in, qh);
445 } 431 }
446} 432}
@@ -2126,7 +2112,7 @@ static int musb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
2126 int ready = qh->is_ready; 2112 int ready = qh->is_ready;
2127 2113
2128 qh->is_ready = 0; 2114 qh->is_ready = 0;
2129 __musb_giveback(musb, urb, 0); 2115 musb_giveback(musb, urb, 0);
2130 qh->is_ready = ready; 2116 qh->is_ready = ready;
2131 2117
2132 /* If nothing else (usually musb_giveback) is using it 2118 /* If nothing else (usually musb_giveback) is using it
@@ -2188,7 +2174,7 @@ musb_h_disable(struct usb_hcd *hcd, struct usb_host_endpoint *hep)
2188 * will activate any of these as it advances. 2174 * will activate any of these as it advances.
2189 */ 2175 */
2190 while (!list_empty(&hep->urb_list)) 2176 while (!list_empty(&hep->urb_list))
2191 __musb_giveback(musb, next_urb(qh), -ESHUTDOWN); 2177 musb_giveback(musb, next_urb(qh), -ESHUTDOWN);
2192 2178
2193 hep->hcpriv = NULL; 2179 hep->hcpriv = NULL;
2194 list_del(&qh->ring); 2180 list_del(&qh->ring);