]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
usb: dwc3: gadget: Handle 0 xfer length for OUT EP
authorTejas Joglekar <tejas.joglekar@synopsys.com>
Tue, 22 Jan 2019 07:56:51 +0000 (13:26 +0530)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Mon, 28 Jan 2019 13:27:07 +0000 (15:27 +0200)
For OUT endpoints, zero-length transfers require MaxPacketSize buffer as
per the DWC_usb3 programming guide 3.30a section 4.2.3.3.

This patch fixes this by explicitly checking zero length
transfer to correctly pad up to MaxPacketSize.

Fixes: c6267a51639b ("usb: dwc3: gadget: align transfers to wMaxPacketSize")
Cc: stable@vger.kernel.org
Signed-off-by: Tejas Joglekar <joglekar@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/dwc3/gadget.c

index bed2ff42780b79dd2cdbc166c564e7fcb786d60a..6c9b76bcc2e173570b7fdae29769d4925b3c971d 100644 (file)
@@ -1119,7 +1119,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
        unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
        unsigned int rem = length % maxp;
 
-       if (rem && usb_endpoint_dir_out(dep->endpoint.desc)) {
+       if ((!length || rem) && usb_endpoint_dir_out(dep->endpoint.desc)) {
                struct dwc3     *dwc = dep->dwc;
                struct dwc3_trb *trb;