Skip to content

Commit 8878598

Browse files
Hans Verkuilmchehab
authored andcommitted
media: vb2: use lock if wait_prepare/finish are NULL
If the wait_prepare or wait_finish callback is set, then call it. If it is NULL and the queue lock pointer is not NULL, then just unlock/lock that mutex. This allows simplifying drivers by dropping the wait_prepare and wait_finish ops (and eventually the vb2_ops_wait_prepare/finish helpers). Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
1 parent c780d01 commit 8878598

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/media/common/videobuf2/videobuf2-core.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,7 +2035,10 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
20352035
* become ready or for streamoff. Driver's lock is released to
20362036
* allow streamoff or qbuf to be called while waiting.
20372037
*/
2038-
call_void_qop(q, wait_prepare, q);
2038+
if (q->ops->wait_prepare)
2039+
call_void_qop(q, wait_prepare, q);
2040+
else if (q->lock)
2041+
mutex_unlock(q->lock);
20392042

20402043
/*
20412044
* All locks have been released, it is safe to sleep now.
@@ -2045,12 +2048,16 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
20452048
!list_empty(&q->done_list) || !q->streaming ||
20462049
q->error);
20472050

2051+
if (q->ops->wait_finish)
2052+
call_void_qop(q, wait_finish, q);
2053+
else if (q->lock)
2054+
mutex_lock(q->lock);
2055+
2056+
q->waiting_in_dqbuf = 0;
20482057
/*
20492058
* We need to reevaluate both conditions again after reacquiring
20502059
* the locks or return an error if one occurred.
20512060
*/
2052-
call_void_qop(q, wait_finish, q);
2053-
q->waiting_in_dqbuf = 0;
20542061
if (ret) {
20552062
dprintk(q, 1, "sleep was interrupted\n");
20562063
return ret;

0 commit comments

Comments
 (0)