From: Felipe Balbi Date: Wed, 22 Mar 2017 11:25:18 +0000 (+0200) Subject: usb: gadget: u_ether: conditionally align transfer size X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=387f869d2579e379ee343f5493dcd360be60f5c6;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git usb: gadget: u_ether: conditionally align transfer size Unless HW sets quirk_ep_out_aligned_size, gadget driver shouldn't make any efforts towards aligning transfers. If the UDC needs, it *must* set the quirk flag. Signed-off-by: Felipe Balbi --- diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c index cba6ff683f2c..a8b40d07e927 100644 --- a/drivers/usb/gadget/function/u_ether.c +++ b/drivers/usb/gadget/function/u_ether.c @@ -178,6 +178,7 @@ static void rx_complete(struct usb_ep *ep, struct usb_request *req); static int rx_submit(struct eth_dev *dev, struct usb_request *req, gfp_t gfp_flags) { + struct usb_gadget *g = dev->gadget; struct sk_buff *skb; int retval = -ENOMEM; size_t size = 0; @@ -209,8 +210,11 @@ rx_submit(struct eth_dev *dev, struct usb_request *req, gfp_t gfp_flags) */ size += sizeof(struct ethhdr) + dev->net->mtu + RX_EXTRA; size += dev->port_usb->header_len; - size += out->maxpacket - 1; - size -= size % out->maxpacket; + + if (g->quirk_ep_out_aligned_size) { + size += out->maxpacket - 1; + size -= size % out->maxpacket; + } if (dev->port_usb->is_fixed) size = max_t(size_t, size, dev->port_usb->fixed_out_len);