ANDROID: usb: gadget: fix MTP enumeration issue under super speed mode
authorJiebing Li <jiebing.li@intel.com>
Tue, 10 Mar 2015 03:24:00 +0000 (11:24 +0800)
committerAmit Pundir <amit.pundir@linaro.org>
Mon, 1 May 2017 09:49:51 +0000 (15:19 +0530)
MTP function doesn't show as a drive in Windows when the device
is connected to PC's USB3 port, because device fails to respond
ACK to BULK OUT transfer request.

This patch modifies MTP OUT request length as multiple of MaxPacketSize
per databook requirement in order to fix this issue.

Patchset: mtp

Change-Id: I090d7880ff00c499dc5ba7fd644b1fe7cd87fcb5
Signed-off-by: Jiebing Li <jiebing.li@intel.com>
Signed-off-by: Wang, Yu <yu.y.wang@intel.com>
Signed-off-by: Russ Weight <russell.h.weight@intel.com>
drivers/usb/gadget/function/f_mtp.c

index d8b69af6e335302824c5f0d52cb478d5b732c34a..b37cc8d87ca44f41cb8922699780a7e20959ab29 100644 (file)
@@ -540,10 +540,12 @@ static ssize_t mtp_read(struct file *fp, char __user *buf,
        ssize_t r = count;
        unsigned xfer;
        int ret = 0;
+       size_t len;
 
        DBG(cdev, "mtp_read(%zu)\n", count);
 
-       if (count > MTP_BULK_BUFFER_SIZE)
+       len = usb_ep_align_maybe(cdev->gadget, dev->ep_out, count);
+       if (len > MTP_BULK_BUFFER_SIZE)
                return -EINVAL;
 
        /* we will block until we're online */
@@ -567,7 +569,7 @@ static ssize_t mtp_read(struct file *fp, char __user *buf,
 requeue_req:
        /* queue a request */
        req = dev->rx_req[0];
-       req->length = count;
+       req->length = len;
        dev->rx_done = 0;
        ret = usb_ep_queue(dev->ep_out, req, GFP_KERNEL);
        if (ret < 0) {