usb: dwc3: ep0: Handle requests greater than wMaxPacketSize
authorMoiz Sonasath <m-sonasath@ti.com>
Wed, 14 Mar 2012 05:44:56 +0000 (00:44 -0500)
committerFelipe Balbi <balbi@ti.com>
Tue, 10 Apr 2012 09:21:43 +0000 (12:21 +0300)
To allow ep0 out transfers of upto bounce buffer size
instead of maxpacketsize, use the transfer size as multiple
of ep0 maxpacket size.

Cc: stable@vger.kernel.org
Signed-off-by: Moiz Sonasath <m-sonasath@ti.com>
Signed-off-by: Partha Basak <p-basak2@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/dwc3/ep0.c

index 25910e251c04b4fb7ce0ef8bb9685573e859b9b9..a40d3bb0f1c220bdc8f59cbbf0970b0b019b6864 100644 (file)
@@ -559,8 +559,12 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
        length = trb->size & DWC3_TRB_SIZE_MASK;
 
        if (dwc->ep0_bounced) {
+               unsigned transfer_size = ur->length;
+               unsigned maxp = ep0->endpoint.maxpacket;
+
+               transfer_size += (maxp - (transfer_size % maxp));
                transferred = min_t(u32, ur->length,
-                               ep0->endpoint.maxpacket - length);
+                               transfer_size - length);
                memcpy(ur->buf, dwc->ep0_bounce, transferred);
                dwc->ep0_bounced = false;
        } else {