diff options
Diffstat (limited to 'drivers/media/video/videobuf2-core.c')
-rw-r--r-- | drivers/media/video/videobuf2-core.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c index 268c7dd..4da3df6 100644 --- a/drivers/media/video/videobuf2-core.c +++ b/drivers/media/video/videobuf2-core.c @@ -2270,10 +2270,9 @@ ssize_t vb2_fop_write(struct file *file, char __user *buf, { struct video_device *vdev = video_devdata(file); struct mutex *lock = vdev->queue->lock ? vdev->queue->lock : vdev->lock; - bool must_lock = !test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags) && lock; int err = -EBUSY; - if (must_lock && mutex_lock_interruptible(lock)) + if (lock && mutex_lock_interruptible(lock)) return -ERESTARTSYS; if (vb2_queue_is_busy(vdev, file)) goto exit; @@ -2282,7 +2281,7 @@ ssize_t vb2_fop_write(struct file *file, char __user *buf, if (err >= 0) vdev->queue->owner = file->private_data; exit: - if (must_lock) + if (lock) mutex_unlock(lock); return err; } @@ -2293,10 +2292,9 @@ ssize_t vb2_fop_read(struct file *file, char __user *buf, { struct video_device *vdev = video_devdata(file); struct mutex *lock = vdev->queue->lock ? vdev->queue->lock : vdev->lock; - bool must_lock = !test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags) && vdev->lock; int err = -EBUSY; - if (must_lock && mutex_lock_interruptible(lock)) + if (lock && mutex_lock_interruptible(lock)) return -ERESTARTSYS; if (vb2_queue_is_busy(vdev, file)) goto exit; @@ -2305,7 +2303,7 @@ ssize_t vb2_fop_read(struct file *file, char __user *buf, if (err >= 0) vdev->queue->owner = file->private_data; exit: - if (must_lock) + if (lock) mutex_unlock(lock); return err; } @@ -2319,11 +2317,6 @@ unsigned int vb2_fop_poll(struct file *file, poll_table *wait) unsigned long req_events = poll_requested_events(wait); unsigned res; void *fileio; - /* Yuck. We really need to get rid of this flag asap. If it is - set, then the core took the serialization lock before calling - poll(). This is being phased out, but for now we have to handle - this case. */ - bool locked = test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags); bool must_lock = false; /* Try to be smart: only lock if polling might start fileio, @@ -2339,9 +2332,9 @@ unsigned int vb2_fop_poll(struct file *file, poll_table *wait) /* If locking is needed, but this helper doesn't know how, then you shouldn't be using this helper but you should write your own. */ - WARN_ON(must_lock && !locked && !lock); + WARN_ON(must_lock && !lock); - if (must_lock && !locked && lock && mutex_lock_interruptible(lock)) + if (must_lock && lock && mutex_lock_interruptible(lock)) return POLLERR; fileio = q->fileio; @@ -2351,7 +2344,7 @@ unsigned int vb2_fop_poll(struct file *file, poll_table *wait) /* If fileio was started, then we have a new queue owner. */ if (must_lock && !fileio && q->fileio) q->owner = file->private_data; - if (must_lock && !locked && lock) + if (must_lock && lock) mutex_unlock(lock); return res; } |