Commit c9cd06b3d6ea825c62e277def929cc4315802b48
Committed by
Greg Kroah-Hartman
1 parent
81ec4e4a51
Exists in
master
and in
39 other branches
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>
Showing 1 changed file with 20 additions and 34 deletions Side-by-side Diff
drivers/usb/musb/musb_host.c
... | ... | @@ -295,9 +295,8 @@ |
295 | 295 | } |
296 | 296 | } |
297 | 297 | |
298 | -/* caller owns controller lock, irqs are blocked */ | |
299 | -static void | |
300 | -__musb_giveback(struct musb *musb, struct urb *urb, int status) | |
298 | +/* Context: caller owns controller lock, IRQs are blocked */ | |
299 | +static void musb_giveback(struct musb *musb, struct urb *urb, int status) | |
301 | 300 | __releases(musb->lock) |
302 | 301 | __acquires(musb->lock) |
303 | 302 | { |
304 | 303 | |
305 | 304 | |
306 | 305 | |
307 | 306 | |
... | ... | @@ -350,15 +349,23 @@ |
350 | 349 | usb_settoggle(urb->dev, qh->epnum, !is_in, csr ? 1 : 0); |
351 | 350 | } |
352 | 351 | |
353 | -/* caller owns controller lock, irqs are blocked */ | |
354 | -static struct musb_qh * | |
355 | -musb_giveback(struct musb_qh *qh, struct urb *urb, int status) | |
352 | +/* | |
353 | + * Advance this hardware endpoint's queue, completing the specified URB and | |
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 | + */ | |
359 | +static 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 | 363 | struct musb_hw_ep *ep = qh->hw_ep; |
358 | - struct musb *musb = ep->musb; | |
359 | - int is_in = usb_pipein(urb->pipe); | |
360 | 364 | int ready = qh->is_ready; |
365 | + int status; | |
361 | 366 | |
367 | + status = (urb->status == -EINPROGRESS) ? 0 : urb->status; | |
368 | + | |
362 | 369 | /* save toggle eagerly, for paranoia */ |
363 | 370 | switch (qh->type) { |
364 | 371 | case USB_ENDPOINT_XFER_BULK: |
365 | 372 | |
... | ... | @@ -366,13 +373,13 @@ |
366 | 373 | musb_save_toggle(qh, is_in, urb); |
367 | 374 | break; |
368 | 375 | case USB_ENDPOINT_XFER_ISOC: |
369 | - if (status == 0 && urb->error_count) | |
376 | + if (urb->error_count) | |
370 | 377 | status = -EXDEV; |
371 | 378 | break; |
372 | 379 | } |
373 | 380 | |
374 | 381 | qh->is_ready = 0; |
375 | - __musb_giveback(musb, urb, status); | |
382 | + musb_giveback(musb, urb, status); | |
376 | 383 | qh->is_ready = ready; |
377 | 384 | |
378 | 385 | /* reclaim resources (and bandwidth) ASAP; deschedule it, and |
379 | 386 | |
380 | 387 | |
... | ... | @@ -416,31 +423,10 @@ |
416 | 423 | break; |
417 | 424 | } |
418 | 425 | } |
419 | - return qh; | |
420 | -} | |
421 | 426 | |
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 | - */ | |
429 | -static void | |
430 | -musb_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 | - | |
440 | 427 | if (qh != NULL && qh->is_ready) { |
441 | 428 | DBG(4, "... next ep%d %cX urb %p\n", |
442 | - hw_ep->epnum, is_in ? 'R' : 'T', | |
443 | - next_urb(qh)); | |
429 | + hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh)); | |
444 | 430 | musb_start_urb(musb, is_in, qh); |
445 | 431 | } |
446 | 432 | } |
... | ... | @@ -2126,7 +2112,7 @@ |
2126 | 2112 | int ready = qh->is_ready; |
2127 | 2113 | |
2128 | 2114 | qh->is_ready = 0; |
2129 | - __musb_giveback(musb, urb, 0); | |
2115 | + musb_giveback(musb, urb, 0); | |
2130 | 2116 | qh->is_ready = ready; |
2131 | 2117 | |
2132 | 2118 | /* If nothing else (usually musb_giveback) is using it |
... | ... | @@ -2188,7 +2174,7 @@ |
2188 | 2174 | * will activate any of these as it advances. |
2189 | 2175 | */ |
2190 | 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 | 2179 | hep->hcpriv = NULL; |
2194 | 2180 | list_del(&qh->ring); |