diff options
author | Sachin Nikam <snikam@nvidia.com> | 2010-05-05 11:45:54 +0530 |
---|---|---|
committer | Gary King <gking@nvidia.com> | 2010-05-07 16:41:58 -0700 |
commit | 17369eee42bba5c1aaaf3a2e9dc79ea55d543e5d (patch) | |
tree | 32f3a2a1fe533cf030b8bce1abcd56df657ff7d2 | |
parent | a22928471875feb95532b42b8ad3718cdd43e1bf (diff) |
tegra_uvc:graceful exit when usb camera is unplugged
Bug 657105
Problem:When the USB Camera is unplugged while preview
VIDIOC_DQBUF ioctl hangs in uvc_queue_waiton()
as it waits on interrupt which will never come,
as USB Camera is unplugged.
Solution:Using wait_event_interruptible_timeout() instead
of wait_event_interruptible() in function uvc_queue_waiton()
with timeout value 250 mSec so as to gracefully exit.
With this change VIDIOC_DQBUF ioctl returns error,
USB Camera driver handles this error to gracefully exit.
Change-Id: I74aebadafb727b66cb1de8d70c6512a4ded63d03
Reviewed-on: http://git-master/r/1294
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Tested-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-by: Gary King <gking@nvidia.com>
-rw-r--r-- | drivers/media/video/uvc/uvc_queue.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/media/video/uvc/uvc_queue.c b/drivers/media/video/uvc/uvc_queue.c index 0155752e4a5a..9870d93cd042 100644 --- a/drivers/media/video/uvc/uvc_queue.c +++ b/drivers/media/video/uvc/uvc_queue.c @@ -23,6 +23,8 @@ #include "uvcvideo.h" +#define UVC_Q_WAITON_TIMEOUT 250 /* mSec */ + /* ------------------------------------------------------------------------ * Video buffers queue management. * @@ -285,9 +287,10 @@ static int uvc_queue_waiton(struct uvc_buffer *buf, int nonblocking) ? 0 : -EAGAIN; } - return wait_event_interruptible(buf->wait, + return wait_event_interruptible_timeout(buf->wait, buf->state != UVC_BUF_STATE_QUEUED && - buf->state != UVC_BUF_STATE_ACTIVE); + buf->state != UVC_BUF_STATE_ACTIVE, + UVC_Q_WAITON_TIMEOUT); } /* |