diff options
author | Mike Lockwood <lockwood@android.com> | 2011-03-25 12:22:22 -0700 |
---|---|---|
committer | Niket Sirsi <nsirsi@nvidia.com> | 2011-07-12 15:04:39 -0700 |
commit | 358a8f04e7adc6b95cca9ef131489525822e7a01 (patch) | |
tree | 42e07208f9bde6605a234c06b22365ef156801da | |
parent | 4bb705abc7eeb3ddb4d64c76bea52f705cda4a17 (diff) |
USB: gadget: f_mtp: Don't block waiting for online state in read()
Return -ENODEV instead if USB is not connected.
Signed-off-by: Mike Lockwood <lockwood@android.com>
(cherry picked from commit 89f57cb6b93c3ac3a3b46480574054e603c47c36)
Change-Id: Ia3527d3f9a2a5a6a4aa56b717602ab28a8716e0e
Reviewed-on: http://git-master/r/36700
Reviewed-by: Amit Kamath <akamath@nvidia.com>
Tested-by: Amit Kamath <akamath@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
-rw-r--r-- | drivers/usb/gadget/f_mtp.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/usb/gadget/f_mtp.c b/drivers/usb/gadget/f_mtp.c index 4de4c68bb8cb..0c3d3e3bfbd5 100644 --- a/drivers/usb/gadget/f_mtp.c +++ b/drivers/usb/gadget/f_mtp.c @@ -472,15 +472,11 @@ static ssize_t mtp_read(struct file *fp, char __user *buf, if (count > BULK_BUFFER_SIZE) return -EINVAL; - /* we will block until we're online */ - DBG(cdev, "mtp_read: waiting for online state\n"); - ret = wait_event_interruptible(dev->read_wq, - dev->state != STATE_OFFLINE); - if (ret < 0) { - r = ret; - goto done; - } spin_lock_irq(&dev->lock); + if (dev->state == STATE_OFFLINE) { + spin_unlock_irq(&dev->lock); + return -ENODEV; + } if (dev->state == STATE_CANCELED) { /* report cancelation to userspace */ dev->state = STATE_READY; |