aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx/em28xx-video.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2008-12-16 18:19:24 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-12-30 06:39:13 -0500
commit29b59417c514a2c5291abb4e3a42e5245ffe6058 (patch)
tree6f257bcbb964919de59ba2cbc483dc876025b771 /drivers/media/video/em28xx/em28xx-video.c
parent7831364f33af9bb7333f333e9a239b1dd2edea1c (diff)
V4L/DVB (9910): em28xx: move res_get locks to the caller routines
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/em28xx/em28xx-video.c')
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 90aedaeb09b9..2d88afefecf5 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -599,12 +599,10 @@ static int res_get(struct em28xx_fh *fh)
599 return rc; 599 return rc;
600 600
601 if (dev->stream_on) 601 if (dev->stream_on)
602 return -EINVAL; 602 return -EBUSY;
603 603
604 mutex_lock(&dev->lock);
605 dev->stream_on = 1; 604 dev->stream_on = 1;
606 fh->stream_on = 1; 605 fh->stream_on = 1;
607 mutex_unlock(&dev->lock);
608 return rc; 606 return rc;
609} 607}
610 608
@@ -1257,8 +1255,12 @@ static int vidioc_streamon(struct file *file, void *priv,
1257 return rc; 1255 return rc;
1258 1256
1259 1257
1260 if (unlikely(res_get(fh) < 0)) 1258 mutex_lock(&dev->lock);
1261 return -EBUSY; 1259 rc = res_get(fh);
1260 mutex_unlock(&dev->lock);
1261
1262 if (unlikely(rc < 0))
1263 return rc;
1262 1264
1263 return (videobuf_streamon(&fh->vb_vidq)); 1265 return (videobuf_streamon(&fh->vb_vidq));
1264} 1266}
@@ -1738,8 +1740,12 @@ em28xx_v4l2_read(struct file *filp, char __user *buf, size_t count,
1738 */ 1740 */
1739 1741
1740 if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { 1742 if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
1741 if (unlikely(res_get(fh))) 1743 mutex_lock(&dev->lock);
1742 return -EBUSY; 1744 rc = res_get(fh);
1745 mutex_unlock(&dev->lock);
1746
1747 if (unlikely(rc < 0))
1748 return rc;
1743 1749
1744 return videobuf_read_stream(&fh->vb_vidq, buf, count, pos, 0, 1750 return videobuf_read_stream(&fh->vb_vidq, buf, count, pos, 0,
1745 filp->f_flags & O_NONBLOCK); 1751 filp->f_flags & O_NONBLOCK);
@@ -1761,7 +1767,11 @@ static unsigned int em28xx_v4l2_poll(struct file *filp, poll_table * wait)
1761 if (rc < 0) 1767 if (rc < 0)
1762 return rc; 1768 return rc;
1763 1769
1764 if (unlikely(res_get(fh) < 0)) 1770 mutex_lock(&dev->lock);
1771 rc = res_get(fh);
1772 mutex_unlock(&dev->lock);
1773
1774 if (unlikely(rc < 0))
1765 return POLLERR; 1775 return POLLERR;
1766 1776
1767 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type) 1777 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type)
@@ -1779,13 +1789,17 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
1779 struct em28xx *dev = fh->dev; 1789 struct em28xx *dev = fh->dev;
1780 int rc; 1790 int rc;
1781 1791
1782 if (unlikely(res_get(fh) < 0))
1783 return -EBUSY;
1784
1785 rc = check_dev(dev); 1792 rc = check_dev(dev);
1786 if (rc < 0) 1793 if (rc < 0)
1787 return rc; 1794 return rc;
1788 1795
1796 mutex_lock(&dev->lock);
1797 rc = res_get(fh);
1798 mutex_unlock(&dev->lock);
1799
1800 if (unlikely(rc < 0))
1801 return rc;
1802
1789 rc = videobuf_mmap_mapper(&fh->vb_vidq, vma); 1803 rc = videobuf_mmap_mapper(&fh->vb_vidq, vma);
1790 1804
1791 em28xx_videodbg("vma start=0x%08lx, size=%ld, ret=%d\n", 1805 em28xx_videodbg("vma start=0x%08lx, size=%ld, ret=%d\n",