aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/stk-webcam.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/stk-webcam.c')
-rw-r--r--drivers/media/video/stk-webcam.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c
index db69bc5556d6..edaea4964513 100644
--- a/drivers/media/video/stk-webcam.c
+++ b/drivers/media/video/stk-webcam.c
@@ -27,7 +27,6 @@
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/errno.h> 28#include <linux/errno.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/kref.h>
31 30
32#include <linux/usb.h> 31#include <linux/usb.h>
33#include <linux/mm.h> 32#include <linux/mm.h>
@@ -560,7 +559,7 @@ static void stk_clean_iso(struct stk_camera *dev)
560 559
561 urb = dev->isobufs[i].urb; 560 urb = dev->isobufs[i].urb;
562 if (urb) { 561 if (urb) {
563 if (atomic_read(&dev->urbs_used)) 562 if (atomic_read(&dev->urbs_used) && is_present(dev))
564 usb_kill_urb(urb); 563 usb_kill_urb(urb);
565 usb_free_urb(urb); 564 usb_free_urb(urb);
566 } 565 }
@@ -689,18 +688,14 @@ static int v4l_stk_release(struct inode *inode, struct file *fp)
689{ 688{
690 struct stk_camera *dev = fp->private_data; 689 struct stk_camera *dev = fp->private_data;
691 690
692 if (dev->owner != fp) { 691 if (dev->owner == fp) {
693 usb_autopm_put_interface(dev->interface); 692 stk_stop_stream(dev);
694 return 0; 693 stk_free_buffers(dev);
694 dev->owner = NULL;
695 } 695 }
696 696
697 stk_stop_stream(dev); 697 if(is_present(dev))
698 698 usb_autopm_put_interface(dev->interface);
699 stk_free_buffers(dev);
700
701 dev->owner = NULL;
702
703 usb_autopm_put_interface(dev->interface);
704 699
705 return 0; 700 return 0;
706} 701}
@@ -714,9 +709,6 @@ static ssize_t v4l_stk_read(struct file *fp, char __user *buf,
714 struct stk_sio_buffer *sbuf; 709 struct stk_sio_buffer *sbuf;
715 struct stk_camera *dev = fp->private_data; 710 struct stk_camera *dev = fp->private_data;
716 711
717 if (dev == NULL)
718 return -EIO;
719
720 if (!is_present(dev)) 712 if (!is_present(dev))
721 return -EIO; 713 return -EIO;
722 if (dev->owner && dev->owner != fp) 714 if (dev->owner && dev->owner != fp)
@@ -773,9 +765,6 @@ static unsigned int v4l_stk_poll(struct file *fp, poll_table *wait)
773{ 765{
774 struct stk_camera *dev = fp->private_data; 766 struct stk_camera *dev = fp->private_data;
775 767
776 if (dev == NULL)
777 return -ENODEV;
778
779 poll_wait(fp, &dev->wait_frame, wait); 768 poll_wait(fp, &dev->wait_frame, wait);
780 769
781 if (!is_present(dev)) 770 if (!is_present(dev))
@@ -1436,7 +1425,7 @@ static void stk_camera_disconnect(struct usb_interface *interface)
1436 wake_up_interruptible(&dev->wait_frame); 1425 wake_up_interruptible(&dev->wait_frame);
1437 stk_remove_sysfs_files(&dev->vdev); 1426 stk_remove_sysfs_files(&dev->vdev);
1438 1427
1439 STK_INFO("Syntek USB2.0 Camera release resources" 1428 STK_INFO("Syntek USB2.0 Camera release resources "
1440 "video device /dev/video%d\n", dev->vdev.minor); 1429 "video device /dev/video%d\n", dev->vdev.minor);
1441 1430
1442 video_unregister_device(&dev->vdev); 1431 video_unregister_device(&dev->vdev);