Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 124414
b: refs/heads/master
c: 29b5941
h: refs/heads/master
v: v3
  • Loading branch information
Mauro Carvalho Chehab committed Dec 30, 2008
1 parent b78aadf commit b86614c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7831364f33af9bb7333f333e9a239b1dd2edea1c
refs/heads/master: 29b59417c514a2c5291abb4e3a42e5245ffe6058
36 changes: 25 additions & 11 deletions trunk/drivers/media/video/em28xx/em28xx-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,12 +599,10 @@ static int res_get(struct em28xx_fh *fh)
return rc;

if (dev->stream_on)
return -EINVAL;
return -EBUSY;

mutex_lock(&dev->lock);
dev->stream_on = 1;
fh->stream_on = 1;
mutex_unlock(&dev->lock);
return rc;
}

Expand Down Expand Up @@ -1257,8 +1255,12 @@ static int vidioc_streamon(struct file *file, void *priv,
return rc;


if (unlikely(res_get(fh) < 0))
return -EBUSY;
mutex_lock(&dev->lock);
rc = res_get(fh);
mutex_unlock(&dev->lock);

if (unlikely(rc < 0))
return rc;

return (videobuf_streamon(&fh->vb_vidq));
}
Expand Down Expand Up @@ -1738,8 +1740,12 @@ em28xx_v4l2_read(struct file *filp, char __user *buf, size_t count,
*/

if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
if (unlikely(res_get(fh)))
return -EBUSY;
mutex_lock(&dev->lock);
rc = res_get(fh);
mutex_unlock(&dev->lock);

if (unlikely(rc < 0))
return rc;

return videobuf_read_stream(&fh->vb_vidq, buf, count, pos, 0,
filp->f_flags & O_NONBLOCK);
Expand All @@ -1761,7 +1767,11 @@ static unsigned int em28xx_v4l2_poll(struct file *filp, poll_table * wait)
if (rc < 0)
return rc;

if (unlikely(res_get(fh) < 0))
mutex_lock(&dev->lock);
rc = res_get(fh);
mutex_unlock(&dev->lock);

if (unlikely(rc < 0))
return POLLERR;

if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type)
Expand All @@ -1779,13 +1789,17 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
struct em28xx *dev = fh->dev;
int rc;

if (unlikely(res_get(fh) < 0))
return -EBUSY;

rc = check_dev(dev);
if (rc < 0)
return rc;

mutex_lock(&dev->lock);
rc = res_get(fh);
mutex_unlock(&dev->lock);

if (unlikely(rc < 0))
return rc;

rc = videobuf_mmap_mapper(&fh->vb_vidq, vma);

em28xx_videodbg("vma start=0x%08lx, size=%ld, ret=%d\n",
Expand Down

0 comments on commit b86614c

Please sign in to comment.