Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 330699
b: refs/heads/master
c: 8422b08
h: refs/heads/master
i:
  330697: ad3be7d
  330695: 20da1ed
v: v3
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Aug 9, 2012
1 parent 238fc35 commit 2828b80
Show file tree
Hide file tree
Showing 2 changed files with 21 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: 1f7e073da5ba4c1b3af8ad0f313e9d3e6447f858
refs/heads/master: 8422b087834f198a63f33c46f34059356cafef9d
31 changes: 20 additions & 11 deletions trunk/drivers/media/video/soc_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,12 @@ static int soc_camera_open(struct file *file)

ici = to_soc_camera_host(icd->parent);

if (mutex_lock_interruptible(&icd->video_lock))
return -ERESTARTSYS;
if (!try_module_get(ici->ops->owner)) {
dev_err(icd->pdev, "Couldn't lock capture bus driver.\n");
return -EINVAL;
ret = -EINVAL;
goto emodule;
}

icd->use_count++;
Expand Down Expand Up @@ -570,6 +573,7 @@ static int soc_camera_open(struct file *file)
}
v4l2_ctrl_handler_setup(&icd->ctrl_handler);
}
mutex_unlock(&icd->video_lock);

file->private_data = icd;
dev_dbg(icd->pdev, "camera device open\n");
Expand All @@ -590,6 +594,8 @@ static int soc_camera_open(struct file *file)
eiciadd:
icd->use_count--;
module_put(ici->ops->owner);
emodule:
mutex_unlock(&icd->video_lock);

return ret;
}
Expand All @@ -599,6 +605,7 @@ static int soc_camera_close(struct file *file)
struct soc_camera_device *icd = file->private_data;
struct soc_camera_host *ici = to_soc_camera_host(icd->parent);

mutex_lock(&icd->video_lock);
icd->use_count--;
if (!icd->use_count) {
struct soc_camera_link *icl = to_soc_camera_link(icd);
Expand All @@ -615,6 +622,7 @@ static int soc_camera_close(struct file *file)

if (icd->streamer == file)
icd->streamer = NULL;
mutex_unlock(&icd->video_lock);

module_put(ici->ops->owner);

Expand Down Expand Up @@ -645,10 +653,13 @@ static int soc_camera_mmap(struct file *file, struct vm_area_struct *vma)
if (icd->streamer != file)
return -EBUSY;

if (mutex_lock_interruptible(&icd->video_lock))
return -ERESTARTSYS;
if (ici->ops->init_videobuf)
err = videobuf_mmap_mapper(&icd->vb_vidq, vma);
else
err = vb2_mmap(&icd->vb2_vidq, vma);
mutex_unlock(&icd->video_lock);

dev_dbg(icd->pdev, "vma start=0x%08lx, size=%ld, ret=%d\n",
(unsigned long)vma->vm_start,
Expand All @@ -662,16 +673,18 @@ static unsigned int soc_camera_poll(struct file *file, poll_table *pt)
{
struct soc_camera_device *icd = file->private_data;
struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
unsigned res = POLLERR;

if (icd->streamer != file)
return -EBUSY;

if (ici->ops->init_videobuf && list_empty(&icd->vb_vidq.stream)) {
dev_err(icd->pdev, "Trying to poll with no queued buffers!\n");
return POLLERR;
}

return ici->ops->poll(file, pt);
mutex_lock(&icd->video_lock);
if (ici->ops->init_videobuf && list_empty(&icd->vb_vidq.stream))
dev_err(icd->pdev, "Trying to poll with no queued buffers!\n");
else
res = ici->ops->poll(file, pt);
mutex_unlock(&icd->video_lock);
return res;
}

void soc_camera_lock(struct vb2_queue *vq)
Expand Down Expand Up @@ -1432,10 +1445,6 @@ static int video_dev_create(struct soc_camera_device *icd)
vdev->tvnorms = V4L2_STD_UNKNOWN;
vdev->ctrl_handler = &icd->ctrl_handler;
vdev->lock = &icd->video_lock;
/* Locking in file operations other than ioctl should be done
by the driver, not the V4L2 core.
This driver needs auditing so that this flag can be removed. */
set_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags);

icd->vdev = vdev;

Expand Down

0 comments on commit 2828b80

Please sign in to comment.