mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-22 00:09:11 +03:00
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>
This commit is contained in:
parent
c780d01cf1
commit
88785982a1
@ -2035,7 +2035,10 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
|
|||||||
* become ready or for streamoff. Driver's lock is released to
|
* become ready or for streamoff. Driver's lock is released to
|
||||||
* allow streamoff or qbuf to be called while waiting.
|
* allow streamoff or qbuf to be called while waiting.
|
||||||
*/
|
*/
|
||||||
call_void_qop(q, wait_prepare, q);
|
if (q->ops->wait_prepare)
|
||||||
|
call_void_qop(q, wait_prepare, q);
|
||||||
|
else if (q->lock)
|
||||||
|
mutex_unlock(q->lock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* All locks have been released, it is safe to sleep now.
|
* 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)
|
|||||||
!list_empty(&q->done_list) || !q->streaming ||
|
!list_empty(&q->done_list) || !q->streaming ||
|
||||||
q->error);
|
q->error);
|
||||||
|
|
||||||
|
if (q->ops->wait_finish)
|
||||||
|
call_void_qop(q, wait_finish, q);
|
||||||
|
else if (q->lock)
|
||||||
|
mutex_lock(q->lock);
|
||||||
|
|
||||||
|
q->waiting_in_dqbuf = 0;
|
||||||
/*
|
/*
|
||||||
* We need to reevaluate both conditions again after reacquiring
|
* We need to reevaluate both conditions again after reacquiring
|
||||||
* the locks or return an error if one occurred.
|
* the locks or return an error if one occurred.
|
||||||
*/
|
*/
|
||||||
call_void_qop(q, wait_finish, q);
|
|
||||||
q->waiting_in_dqbuf = 0;
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dprintk(q, 1, "sleep was interrupted\n");
|
dprintk(q, 1, "sleep was interrupted\n");
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user