From a6cca35edd4cdcab3bcbfc3f3aca5dbdc7bc9f3e Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 13 Oct 2008 16:54:52 -0400 Subject: stk-webcam: minor cleanup From: David Ellingsworth This patch: 1) removes the unnecessary kref.h include file 2) removes unnecessary pointer validation from read and poll routines. (Neither poll nor read may be called unless a call to open succeeds. A successful call to open will always set the file private_data pointer. Verifying that it is not null is therefore unnecessary. The associated release and mmap calls currently ignore this check.) 3) adds a space to syslog output. 4) removes an unused function prototype. Signed-off-by: David Ellingsworth Signed-off-by: Mauro Carvalho Chehab --- linux/drivers/media/video/stk-webcam.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'linux/drivers/media/video/stk-webcam.c') diff --git a/linux/drivers/media/video/stk-webcam.c b/linux/drivers/media/video/stk-webcam.c index 8c1817a47..11451518c 100644 --- a/linux/drivers/media/video/stk-webcam.c +++ b/linux/drivers/media/video/stk-webcam.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include @@ -715,9 +714,6 @@ static ssize_t v4l_stk_read(struct file *fp, char __user *buf, struct stk_sio_buffer *sbuf; struct stk_camera *dev = fp->private_data; - if (dev == NULL) - return -EIO; - if (!is_present(dev)) return -EIO; if (dev->owner && dev->owner != fp) @@ -774,9 +770,6 @@ static unsigned int v4l_stk_poll(struct file *fp, poll_table *wait) { struct stk_camera *dev = fp->private_data; - if (dev == NULL) - return -ENODEV; - poll_wait(fp, &dev->wait_frame, wait); if (!is_present(dev)) @@ -1437,7 +1430,7 @@ static void stk_camera_disconnect(struct usb_interface *interface) wake_up_interruptible(&dev->wait_frame); stk_remove_sysfs_files(&dev->vdev); - STK_INFO("Syntek USB2.0 Camera release resources" + STK_INFO("Syntek USB2.0 Camera release resources " "video device /dev/video%d\n", dev->vdev.minor); video_unregister_device(&dev->vdev); -- cgit v1.2.3 From fe6c63a6af78ccde86f29207003db1c897e7a8c4 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 14 Oct 2008 01:31:15 +0000 Subject: stk-webcam: fix crash on close after disconnect From: David Ellingsworth This patch prevents stk-webcam from updating usb device information once the camera has been removed. This prevents a crash that would otherwise occur if the camera is disconnected while it is still in use. Signed-off-by: David Ellingsworth Signed-off-by: Mauro Carvalho Chehab --- linux/drivers/media/video/stk-webcam.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'linux/drivers/media/video/stk-webcam.c') diff --git a/linux/drivers/media/video/stk-webcam.c b/linux/drivers/media/video/stk-webcam.c index 11451518c..f606300e8 100644 --- a/linux/drivers/media/video/stk-webcam.c +++ b/linux/drivers/media/video/stk-webcam.c @@ -560,7 +560,7 @@ static void stk_clean_iso(struct stk_camera *dev) urb = dev->isobufs[i].urb; if (urb) { - if (atomic_read(&dev->urbs_used)) + if (atomic_read(&dev->urbs_used) && is_present(dev)) usb_kill_urb(urb); usb_free_urb(urb); } @@ -689,18 +689,14 @@ static int v4l_stk_release(struct inode *inode, struct file *fp) { struct stk_camera *dev = fp->private_data; - if (dev->owner != fp) { - usb_autopm_put_interface(dev->interface); - return 0; + if (dev->owner == fp) { + stk_stop_stream(dev); + stk_free_buffers(dev); + dev->owner = NULL; } - stk_stop_stream(dev); - - stk_free_buffers(dev); - - dev->owner = NULL; - - usb_autopm_put_interface(dev->interface); + if(is_present(dev)) + usb_autopm_put_interface(dev->interface); return 0; } -- cgit v1.2.3