]> git.karo-electronics.de Git - linux-beck.git/commitdiff
usb: gadget: fix request length error for isoc transfer
authorPeter Chen <peter.chen@nxp.com>
Tue, 8 Nov 2016 02:08:24 +0000 (10:08 +0800)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Fri, 18 Nov 2016 11:54:09 +0000 (13:54 +0200)
For isoc endpoint descriptor, the wMaxPacketSize is not real max packet
size (see Table 9-13. Standard Endpoint Descriptor, USB 2.0 specifcation),
it may contain the number of packet, so the real max packet should be
ep->desc->wMaxPacketSize && 0x7ff.

Cc: Felipe F. Tonello <eu@felipetonello.com>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Fixes: 16b114a6d797 ("usb: gadget: fix usb_ep_align_maybe
  endianness and new usb_ep_aligna")

Signed-off-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
include/linux/usb/gadget.h

index 8e81f9eb95e40134f52cd49bd9c3cf5a948735f7..e4516e9ded0f437b73f171678833425d9f29a442 100644 (file)
@@ -429,7 +429,9 @@ static inline struct usb_gadget *dev_to_usb_gadget(struct device *dev)
  */
 static inline size_t usb_ep_align(struct usb_ep *ep, size_t len)
 {
-       return round_up(len, (size_t)le16_to_cpu(ep->desc->wMaxPacketSize));
+       int max_packet_size = (size_t)usb_endpoint_maxp(ep->desc) & 0x7ff;
+
+       return round_up(len, max_packet_size);
 }
 
 /**