OSDN Git Service

USB: gadget: f_mtp: Make sure request is dequeued if transfer is canceled
authorMike Lockwood <lockwood@android.com>
Thu, 13 Jan 2011 21:19:57 +0000 (16:19 -0500)
committerBrian Swetland <swetland@google.com>
Tue, 29 Mar 2011 20:58:02 +0000 (13:58 -0700)
If the host cancels a file transfer while we have a read request pending,
call usb_ep_dequeue to cancel the read.
Also return -ECANCELED from mtp_ioctl if we are canceled in MTP_RECEIVE_FILE

Signed-off-by: Mike Lockwood <lockwood@android.com>
drivers/usb/gadget/f_mtp.c

index 64fe3b3..e07224f 100644 (file)
@@ -756,8 +756,10 @@ static void receive_file_work(struct work_struct *data)
                        /* wait for our last read to complete */
                        ret = wait_event_interruptible(dev->read_wq,
                                dev->rx_done || dev->state != STATE_BUSY);
-                       if (ret < 0 || dev->state != STATE_BUSY) {
-                               r = ret;
+                       if (dev->state == STATE_CANCELED) {
+                               r = -ECANCELED;
+                               if (!dev->rx_done)
+                                       usb_ep_dequeue(dev->ep_out, read_req);
                                break;
                        }
                        /* if xfer_file_length is 0xFFFFFFFF, then we read until