diff options
author | Sergei Shtylyov <sshtylyov@ru.mvista.com> | 2009-03-27 15:54:21 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-06-16 00:44:40 -0400 |
commit | 846099a61cf549f450178f1fb3e27adcbd9dcfc2 (patch) | |
tree | f6c59fab37b8e81124d6a62f66c3a4405f96db60 /drivers/usb/musb/musb_host.c | |
parent | 37e3ee991091e08d4902e3d2694c723446a89a8d (diff) |
musb_host: refactor musb_save_toggle() (take 2)
Refactor musb_save_toggle() as follows:
- replace 'struct musb_hw_ep *ep' parameter by 'struct
musb_qh *qh' to avoid re-calculating this value
- move usb_settogle() call out of the *if* operator.
This is a net minor shrink of source and object code.
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/musb_host.c')
-rw-r--r-- | drivers/usb/musb/musb_host.c | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index db1b57415ec7..bf194d244533 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c | |||
@@ -321,35 +321,24 @@ __acquires(musb->lock) | |||
321 | spin_lock(&musb->lock); | 321 | spin_lock(&musb->lock); |
322 | } | 322 | } |
323 | 323 | ||
324 | /* for bulk/interrupt endpoints only */ | 324 | /* For bulk/interrupt endpoints only */ |
325 | static inline void | 325 | static inline void musb_save_toggle(struct musb_qh *qh, int is_in, |
326 | musb_save_toggle(struct musb_hw_ep *ep, int is_in, struct urb *urb) | 326 | struct urb *urb) |
327 | { | 327 | { |
328 | struct usb_device *udev = urb->dev; | 328 | void __iomem *epio = qh->hw_ep->regs; |
329 | u16 csr; | 329 | u16 csr; |
330 | void __iomem *epio = ep->regs; | ||
331 | struct musb_qh *qh; | ||
332 | 330 | ||
333 | /* FIXME: the current Mentor DMA code seems to have | 331 | /* |
332 | * FIXME: the current Mentor DMA code seems to have | ||
334 | * problems getting toggle correct. | 333 | * problems getting toggle correct. |
335 | */ | 334 | */ |
336 | 335 | ||
337 | if (is_in || ep->is_shared_fifo) | 336 | if (is_in) |
338 | qh = ep->in_qh; | 337 | csr = musb_readw(epio, MUSB_RXCSR) & MUSB_RXCSR_H_DATATOGGLE; |
339 | else | 338 | else |
340 | qh = ep->out_qh; | 339 | csr = musb_readw(epio, MUSB_TXCSR) & MUSB_TXCSR_H_DATATOGGLE; |
341 | 340 | ||
342 | if (!is_in) { | 341 | usb_settoggle(urb->dev, qh->epnum, !is_in, csr ? 1 : 0); |
343 | csr = musb_readw(epio, MUSB_TXCSR); | ||
344 | usb_settoggle(udev, qh->epnum, 1, | ||
345 | (csr & MUSB_TXCSR_H_DATATOGGLE) | ||
346 | ? 1 : 0); | ||
347 | } else { | ||
348 | csr = musb_readw(epio, MUSB_RXCSR); | ||
349 | usb_settoggle(udev, qh->epnum, 0, | ||
350 | (csr & MUSB_RXCSR_H_DATATOGGLE) | ||
351 | ? 1 : 0); | ||
352 | } | ||
353 | } | 342 | } |
354 | 343 | ||
355 | /* caller owns controller lock, irqs are blocked */ | 344 | /* caller owns controller lock, irqs are blocked */ |
@@ -365,7 +354,7 @@ musb_giveback(struct musb_qh *qh, struct urb *urb, int status) | |||
365 | switch (qh->type) { | 354 | switch (qh->type) { |
366 | case USB_ENDPOINT_XFER_BULK: | 355 | case USB_ENDPOINT_XFER_BULK: |
367 | case USB_ENDPOINT_XFER_INT: | 356 | case USB_ENDPOINT_XFER_INT: |
368 | musb_save_toggle(ep, is_in, urb); | 357 | musb_save_toggle(qh, is_in, urb); |
369 | break; | 358 | break; |
370 | case USB_ENDPOINT_XFER_ISOC: | 359 | case USB_ENDPOINT_XFER_ISOC: |
371 | if (status == 0 && urb->error_count) | 360 | if (status == 0 && urb->error_count) |
@@ -1427,7 +1416,7 @@ static void musb_bulk_rx_nak_timeout(struct musb *musb, struct musb_hw_ep *ep) | |||
1427 | urb->actual_length += dma->actual_len; | 1416 | urb->actual_length += dma->actual_len; |
1428 | dma->actual_len = 0L; | 1417 | dma->actual_len = 0L; |
1429 | } | 1418 | } |
1430 | musb_save_toggle(ep, 1, urb); | 1419 | musb_save_toggle(cur_qh, 1, urb); |
1431 | 1420 | ||
1432 | /* move cur_qh to end of queue */ | 1421 | /* move cur_qh to end of queue */ |
1433 | list_move_tail(&cur_qh->ring, &musb->in_bulk); | 1422 | list_move_tail(&cur_qh->ring, &musb->in_bulk); |