diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2012-06-22 06:29:35 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-07-06 16:30:54 -0400 |
commit | 5a5adf6b669cf1a3dd2af419cd68a4c491f384a3 (patch) | |
tree | 42b1c4709c3c5cca04fb15bd369e6ae4921645d4 /drivers/media/video/v4l2-dev.c | |
parent | 5d44f5e3e388739f017a74e73dab2a995673915f (diff) |
[media] v4l2-dev/ioctl.c: add vb2_queue support to video_device
This prepares struct video_device for easier integration with vb2.
It also introduces a new lock that protects the vb2_queue. It is up
to the driver to use it or not. And the driver can associate an owner
filehandle with the queue to check whether queuing requests are
permitted for the calling filehandle.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/v4l2-dev.c')
-rw-r--r-- | drivers/media/video/v4l2-dev.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c index c2122e53f051..b82778174eef 100644 --- a/drivers/media/video/v4l2-dev.c +++ b/drivers/media/video/v4l2-dev.c | |||
@@ -348,20 +348,14 @@ static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
348 | int ret = -ENODEV; | 348 | int ret = -ENODEV; |
349 | 349 | ||
350 | if (vdev->fops->unlocked_ioctl) { | 350 | if (vdev->fops->unlocked_ioctl) { |
351 | bool locked = false; | 351 | struct mutex *lock = v4l2_ioctl_get_lock(vdev, cmd); |
352 | 352 | ||
353 | if (vdev->lock) { | 353 | if (lock && mutex_lock_interruptible(lock)) |
354 | /* always lock unless the cmd is marked as "don't use lock" */ | 354 | return -ERESTARTSYS; |
355 | locked = !v4l2_is_known_ioctl(cmd) || | ||
356 | !test_bit(_IOC_NR(cmd), vdev->disable_locking); | ||
357 | |||
358 | if (locked && mutex_lock_interruptible(vdev->lock)) | ||
359 | return -ERESTARTSYS; | ||
360 | } | ||
361 | if (video_is_registered(vdev)) | 355 | if (video_is_registered(vdev)) |
362 | ret = vdev->fops->unlocked_ioctl(filp, cmd, arg); | 356 | ret = vdev->fops->unlocked_ioctl(filp, cmd, arg); |
363 | if (locked) | 357 | if (lock) |
364 | mutex_unlock(vdev->lock); | 358 | mutex_unlock(lock); |
365 | } else if (vdev->fops->ioctl) { | 359 | } else if (vdev->fops->ioctl) { |
366 | /* This code path is a replacement for the BKL. It is a major | 360 | /* This code path is a replacement for the BKL. It is a major |
367 | * hack but it will have to do for those drivers that are not | 361 | * hack but it will have to do for those drivers that are not |