diff options
author | Brandon Philips <bphilips@suse.de> | 2007-09-27 19:55:17 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-10-09 23:03:05 -0400 |
commit | ba32bd95d431525ad2ffac97cadf9ee40b63939e (patch) | |
tree | edb0f38f00c980bd4c95bd82093c8cfad9653a26 /drivers/media/video/vivi.c | |
parent | 85c7c70bc241d506dffc1879158f77f8aac69734 (diff) |
V4L/DVB (6275): V4L: vivi.c remove the "resource" locking
The "resource" locking in vivi isn't needed since
streamon/streamoff/read_stream do mutual exclusion using
q->reading/q->streaming.
Plus it is sort of broken:
a) res_locked() use in vivi_read() is racey.
b) res_free() calls mutex_lock twice causing streamoff to break
Signed-off-by: Brandon Philips <bphilips@suse.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/vivi.c')
-rw-r--r-- | drivers/media/video/vivi.c | 48 |
1 files changed, 4 insertions, 44 deletions
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index cdef622f6b32..82755091648b 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c | |||
@@ -170,7 +170,6 @@ struct vivi_dev { | |||
170 | int users; | 170 | int users; |
171 | 171 | ||
172 | /* various device info */ | 172 | /* various device info */ |
173 | unsigned int resources; | ||
174 | struct video_device vfd; | 173 | struct video_device vfd; |
175 | 174 | ||
176 | struct vivi_dmaqueue vidq; | 175 | struct vivi_dmaqueue vidq; |
@@ -727,40 +726,6 @@ static struct videobuf_queue_ops vivi_video_qops = { | |||
727 | }; | 726 | }; |
728 | 727 | ||
729 | /* ------------------------------------------------------------------ | 728 | /* ------------------------------------------------------------------ |
730 | IOCTL handling | ||
731 | ------------------------------------------------------------------*/ | ||
732 | |||
733 | |||
734 | static int res_get(struct vivi_dev *dev, struct vivi_fh *fh) | ||
735 | { | ||
736 | /* is it free? */ | ||
737 | mutex_lock(&dev->lock); | ||
738 | if (dev->resources) { | ||
739 | /* no, someone else uses it */ | ||
740 | mutex_unlock(&dev->lock); | ||
741 | return 0; | ||
742 | } | ||
743 | /* it's free, grab it */ | ||
744 | dev->resources =1; | ||
745 | dprintk(1,"res: get\n"); | ||
746 | mutex_unlock(&dev->lock); | ||
747 | return 1; | ||
748 | } | ||
749 | |||
750 | static int res_locked(struct vivi_dev *dev) | ||
751 | { | ||
752 | return (dev->resources); | ||
753 | } | ||
754 | |||
755 | static void res_free(struct vivi_dev *dev, struct vivi_fh *fh) | ||
756 | { | ||
757 | mutex_lock(&dev->lock); | ||
758 | dev->resources = 0; | ||
759 | dprintk(1,"res: put\n"); | ||
760 | mutex_lock(&dev->lock); | ||
761 | } | ||
762 | |||
763 | /* ------------------------------------------------------------------ | ||
764 | IOCTL vidioc handling | 729 | IOCTL vidioc handling |
765 | ------------------------------------------------------------------*/ | 730 | ------------------------------------------------------------------*/ |
766 | static int vidioc_querycap (struct file *file, void *priv, | 731 | static int vidioc_querycap (struct file *file, void *priv, |
@@ -913,9 +878,7 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | |||
913 | if (i != fh->type) | 878 | if (i != fh->type) |
914 | return -EINVAL; | 879 | return -EINVAL; |
915 | 880 | ||
916 | if (!res_get(dev,fh)) | 881 | return videobuf_streamon(&fh->vb_vidq); |
917 | return -EBUSY; | ||
918 | return (videobuf_streamon(&fh->vb_vidq)); | ||
919 | } | 882 | } |
920 | 883 | ||
921 | static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | 884 | static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) |
@@ -928,10 +891,7 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | |||
928 | if (i != fh->type) | 891 | if (i != fh->type) |
929 | return -EINVAL; | 892 | return -EINVAL; |
930 | 893 | ||
931 | videobuf_streamoff(&fh->vb_vidq); | 894 | return videobuf_streamoff(&fh->vb_vidq); |
932 | res_free(dev,fh); | ||
933 | |||
934 | return (0); | ||
935 | } | 895 | } |
936 | 896 | ||
937 | static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *i) | 897 | static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *i) |
@@ -1096,10 +1056,10 @@ static ssize_t | |||
1096 | vivi_read(struct file *file, char __user *data, size_t count, loff_t *ppos) | 1056 | vivi_read(struct file *file, char __user *data, size_t count, loff_t *ppos) |
1097 | { | 1057 | { |
1098 | struct vivi_fh *fh = file->private_data; | 1058 | struct vivi_fh *fh = file->private_data; |
1059 | struct vivi_dev *dev = fh->dev; | ||
1060 | struct videobuf_queue *q = &fh->vb_vidq; | ||
1099 | 1061 | ||
1100 | if (fh->type==V4L2_BUF_TYPE_VIDEO_CAPTURE) { | 1062 | if (fh->type==V4L2_BUF_TYPE_VIDEO_CAPTURE) { |
1101 | if (res_locked(fh->dev)) | ||
1102 | return -EBUSY; | ||
1103 | return videobuf_read_stream(&fh->vb_vidq, data, count, ppos, 0, | 1063 | return videobuf_read_stream(&fh->vb_vidq, data, count, ppos, 0, |
1104 | file->f_flags & O_NONBLOCK); | 1064 | file->f_flags & O_NONBLOCK); |
1105 | } | 1065 | } |