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 268c7dd4f82..4da3df61901 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, | |||
2270 | { | 2270 | { |
2271 | struct video_device *vdev = video_devdata(file); | 2271 | struct video_device *vdev = video_devdata(file); |
2272 | struct mutex *lock = vdev->queue->lock ? vdev->queue->lock : vdev->lock; | 2272 | struct mutex *lock = vdev->queue->lock ? vdev->queue->lock : vdev->lock; |
2273 | bool must_lock = !test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags) && lock; | ||
2274 | int err = -EBUSY; | 2273 | int err = -EBUSY; |
2275 | 2274 | ||
2276 | if (must_lock && mutex_lock_interruptible(lock)) | 2275 | if (lock && mutex_lock_interruptible(lock)) |
2277 | return -ERESTARTSYS; | 2276 | return -ERESTARTSYS; |
2278 | if (vb2_queue_is_busy(vdev, file)) | 2277 | if (vb2_queue_is_busy(vdev, file)) |
2279 | goto exit; | 2278 | goto exit; |
@@ -2282,7 +2281,7 @@ ssize_t vb2_fop_write(struct file *file, char __user *buf, | |||
2282 | if (err >= 0) | 2281 | if (err >= 0) |
2283 | vdev->queue->owner = file->private_data; | 2282 | vdev->queue->owner = file->private_data; |
2284 | exit: | 2283 | exit: |
2285 | if (must_lock) | 2284 | if (lock) |
2286 | mutex_unlock(lock); | 2285 | mutex_unlock(lock); |
2287 | return err; | 2286 | return err; |
2288 | } | 2287 | } |
@@ -2293,10 +2292,9 @@ ssize_t vb2_fop_read(struct file *file, char __user *buf, | |||
2293 | { | 2292 | { |
2294 | struct video_device *vdev = video_devdata(file); | 2293 | struct video_device *vdev = video_devdata(file); |
2295 | struct mutex *lock = vdev->queue->lock ? vdev->queue->lock : vdev->lock; | 2294 | struct mutex *lock = vdev->queue->lock ? vdev->queue->lock : vdev->lock; |
2296 | bool must_lock = !test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags) && vdev->lock; | ||
2297 | int err = -EBUSY; | 2295 | int err = -EBUSY; |
2298 | 2296 | ||
2299 | if (must_lock && mutex_lock_interruptible(lock)) | 2297 | if (lock && mutex_lock_interruptible(lock)) |
2300 | return -ERESTARTSYS; | 2298 | return -ERESTARTSYS; |
2301 | if (vb2_queue_is_busy(vdev, file)) | 2299 | if (vb2_queue_is_busy(vdev, file)) |
2302 | goto exit; | 2300 | goto exit; |
@@ -2305,7 +2303,7 @@ ssize_t vb2_fop_read(struct file *file, char __user *buf, | |||
2305 | if (err >= 0) | 2303 | if (err >= 0) |
2306 | vdev->queue->owner = file->private_data; | 2304 | vdev->queue->owner = file->private_data; |
2307 | exit: | 2305 | exit: |
2308 | if (must_lock) | 2306 | if (lock) |
2309 | mutex_unlock(lock); | 2307 | mutex_unlock(lock); |
2310 | return err; | 2308 | return err; |
2311 | } | 2309 | } |
@@ -2319,11 +2317,6 @@ unsigned int vb2_fop_poll(struct file *file, poll_table *wait) | |||
2319 | unsigned long req_events = poll_requested_events(wait); | 2317 | unsigned long req_events = poll_requested_events(wait); |
2320 | unsigned res; | 2318 | unsigned res; |
2321 | void *fileio; | 2319 | void *fileio; |
2322 | /* Yuck. We really need to get rid of this flag asap. If it is | ||
2323 | set, then the core took the serialization lock before calling | ||
2324 | poll(). This is being phased out, but for now we have to handle | ||
2325 | this case. */ | ||
2326 | bool locked = test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags); | ||
2327 | bool must_lock = false; | 2320 | bool must_lock = false; |
2328 | 2321 | ||
2329 | /* Try to be smart: only lock if polling might start fileio, | 2322 | /* 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) | |||
2339 | 2332 | ||
2340 | /* If locking is needed, but this helper doesn't know how, then you | 2333 | /* If locking is needed, but this helper doesn't know how, then you |
2341 | shouldn't be using this helper but you should write your own. */ | 2334 | shouldn't be using this helper but you should write your own. */ |
2342 | WARN_ON(must_lock && !locked && !lock); | 2335 | WARN_ON(must_lock && !lock); |
2343 | 2336 | ||
2344 | if (must_lock && !locked && lock && mutex_lock_interruptible(lock)) | 2337 | if (must_lock && lock && mutex_lock_interruptible(lock)) |
2345 | return POLLERR; | 2338 | return POLLERR; |
2346 | 2339 | ||
2347 | fileio = q->fileio; | 2340 | fileio = q->fileio; |
@@ -2351,7 +2344,7 @@ unsigned int vb2_fop_poll(struct file *file, poll_table *wait) | |||
2351 | /* If fileio was started, then we have a new queue owner. */ | 2344 | /* If fileio was started, then we have a new queue owner. */ |
2352 | if (must_lock && !fileio && q->fileio) | 2345 | if (must_lock && !fileio && q->fileio) |
2353 | q->owner = file->private_data; | 2346 | q->owner = file->private_data; |
2354 | if (must_lock && !locked && lock) | 2347 | if (must_lock && lock) |
2355 | mutex_unlock(lock); | 2348 | mutex_unlock(lock); |
2356 | return res; | 2349 | return res; |
2357 | } | 2350 | } |