[2/8] usb: musb: use length of out short packet to configure dma

Message ID 1300202671-12818-3-git-send-email-mian.yousaf.kaukab@stericsson.com
State New
Headers show

Commit Message

Mian Yousaf Kaukab March 15, 2011, 3:24 p.m.
For Inventra dma, dma is configured for rx transfers after receiving first
packet (MUSB_RXCSR_RXPKTRDY set in RXCSR).  DMA is configured based on the
requested length or the maximum length dma can handle. However, if the
received packet is less than the maximum packet size, length of this packet
should be used to configure the dma. As it will be the only packet to transfer
for this request.

Signed-off-by: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
---
 drivers/usb/musb/musb_gadget.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

Patch

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 419ca3e..ba5d5bd 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -731,7 +731,13 @@  static void rxstate(struct musb *musb, struct musb_request *req)
 				if (request->actual < request->length) {
 					int transfer_size = 0;
 #ifdef USE_MODE1
-					transfer_size = min(request->length - request->actual,
+					/* In case first packet is short */
+					if (len < musb_ep->packet_sz)
+						transfer_size = len;
+					else
+						transfer_size =
+							min(request->length -
+							request->actual,
 							channel->max_len);
 #else
 					transfer_size = min(request->length - request->actual,