aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb
diff options
context:
space:
mode:
authorSergei Shtylyov <sshtylyov@ru.mvista.com>2012-07-16 15:25:04 -0400
committerFelipe Balbi <balbi@ti.com>2012-08-03 02:34:38 -0400
commitf0443afd1d82b07305df1511a6055311047fdfc6 (patch)
treefe467995647aa46f71733ee85ca4887cbcb264f3 /drivers/usb/musb
parent0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (diff)
usb: musb: gadget: use variables according to their names in rxstate()
In rxstate(), improper types are given to 'fifo_count' and 'len' variables, and these variables are not used in accordance to their names (up to the certain point), i.e. 'len' to hold the size of a packet in the RX FIFO, and 'fifo_count' to hold a difference between 'request->length' and 'request->actual'... Interchange the variables up to the point where their use starts to make sense again. Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb')
-rw-r--r--drivers/usb/musb/musb_gadget.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index f7194cf65aba..49d7bee7dbde 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -644,8 +644,8 @@ static void rxstate(struct musb *musb, struct musb_request *req)
644 struct usb_request *request = &req->request; 644 struct usb_request *request = &req->request;
645 struct musb_ep *musb_ep; 645 struct musb_ep *musb_ep;
646 void __iomem *epio = musb->endpoints[epnum].regs; 646 void __iomem *epio = musb->endpoints[epnum].regs;
647 unsigned fifo_count = 0; 647 unsigned len = 0;
648 u16 len; 648 u16 fifo_count;
649 u16 csr = musb_readw(epio, MUSB_RXCSR); 649 u16 csr = musb_readw(epio, MUSB_RXCSR);
650 struct musb_hw_ep *hw_ep = &musb->endpoints[epnum]; 650 struct musb_hw_ep *hw_ep = &musb->endpoints[epnum];
651 u8 use_mode_1; 651 u8 use_mode_1;
@@ -655,7 +655,7 @@ static void rxstate(struct musb *musb, struct musb_request *req)
655 else 655 else
656 musb_ep = &hw_ep->ep_out; 656 musb_ep = &hw_ep->ep_out;
657 657
658 len = musb_ep->packet_sz; 658 fifo_count = musb_ep->packet_sz;
659 659
660 /* Check if EP is disabled */ 660 /* Check if EP is disabled */
661 if (!musb_ep->desc) { 661 if (!musb_ep->desc) {
@@ -704,7 +704,7 @@ static void rxstate(struct musb *musb, struct musb_request *req)
704 } 704 }
705 705
706 if (csr & MUSB_RXCSR_RXPKTRDY) { 706 if (csr & MUSB_RXCSR_RXPKTRDY) {
707 len = musb_readw(epio, MUSB_RXCOUNT); 707 fifo_count = musb_readw(epio, MUSB_RXCOUNT);
708 708
709 /* 709 /*
710 * Enable Mode 1 on RX transfers only when short_not_ok flag 710 * Enable Mode 1 on RX transfers only when short_not_ok flag
@@ -712,7 +712,7 @@ static void rxstate(struct musb *musb, struct musb_request *req)
712 * file_storage and f_mass_storage drivers 712 * file_storage and f_mass_storage drivers
713 */ 713 */
714 714
715 if (request->short_not_ok && len == musb_ep->packet_sz) 715 if (request->short_not_ok && fifo_count == musb_ep->packet_sz)
716 use_mode_1 = 1; 716 use_mode_1 = 1;
717 else 717 else
718 use_mode_1 = 0; 718 use_mode_1 = 0;
@@ -780,7 +780,7 @@ static void rxstate(struct musb *musb, struct musb_request *req)
780 musb_ep->dma->desired_mode = 1; 780 musb_ep->dma->desired_mode = 1;
781 } else { 781 } else {
782 transfer_size = min(request->length - request->actual, 782 transfer_size = min(request->length - request->actual,
783 (unsigned)len); 783 (unsigned)fifo_count);
784 musb_ep->dma->desired_mode = 0; 784 musb_ep->dma->desired_mode = 0;
785 } 785 }
786 786
@@ -808,8 +808,8 @@ static void rxstate(struct musb *musb, struct musb_request *req)
808 channel = musb_ep->dma; 808 channel = musb_ep->dma;
809 809
810 /* In case first packet is short */ 810 /* In case first packet is short */
811 if (len < musb_ep->packet_sz) 811 if (fifo_count < musb_ep->packet_sz)
812 transfer_size = len; 812 transfer_size = fifo_count;
813 else if (request->short_not_ok) 813 else if (request->short_not_ok)
814 transfer_size = min(request->length - 814 transfer_size = min(request->length -
815 request->actual, 815 request->actual,
@@ -817,7 +817,7 @@ static void rxstate(struct musb *musb, struct musb_request *req)
817 else 817 else
818 transfer_size = min(request->length - 818 transfer_size = min(request->length -
819 request->actual, 819 request->actual,
820 (unsigned)len); 820 (unsigned)fifo_count);
821 821
822 csr &= ~MUSB_RXCSR_DMAMODE; 822 csr &= ~MUSB_RXCSR_DMAMODE;
823 csr |= (MUSB_RXCSR_DMAENAB | 823 csr |= (MUSB_RXCSR_DMAENAB |
@@ -845,10 +845,10 @@ static void rxstate(struct musb *musb, struct musb_request *req)
845 } 845 }
846#endif /* Mentor's DMA */ 846#endif /* Mentor's DMA */
847 847
848 fifo_count = request->length - request->actual; 848 len = request->length - request->actual;
849 dev_dbg(musb->controller, "%s OUT/RX pio fifo %d/%d, maxpacket %d\n", 849 dev_dbg(musb->controller, "%s OUT/RX pio fifo %d/%d, maxpacket %d\n",
850 musb_ep->end_point.name, 850 musb_ep->end_point.name,
851 len, fifo_count, 851 fifo_count, len,
852 musb_ep->packet_sz); 852 musb_ep->packet_sz);
853 853
854 fifo_count = min_t(unsigned, len, fifo_count); 854 fifo_count = min_t(unsigned, len, fifo_count);
@@ -901,7 +901,8 @@ static void rxstate(struct musb *musb, struct musb_request *req)
901 } 901 }
902 902
903 /* reach the end or short packet detected */ 903 /* reach the end or short packet detected */
904 if (request->actual == request->length || len < musb_ep->packet_sz) 904 if (request->actual == request->length ||
905 fifo_count < musb_ep->packet_sz)
905 musb_g_giveback(musb_ep, request, 0); 906 musb_g_giveback(musb_ep, request, 0);
906} 907}
907 908