From 97397687886aa8ecd4ec603fab9e70e970c11597 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 20 Sep 2010 17:24:30 -0300 Subject: V4L/DVB: videobuf: prepare to make locking optional in videobuf Currently videobuf uses the vb_lock mutex to lock its data structures. But this locking will (optionally) move into the v4l2 core, which means that in that case vb_lock shouldn't be used since the external lock is already held. Prepare for this by adding a pointer to such an external mutex and don't lock if that pointer is set. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/videobuf-core.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/media/videobuf-core.h') diff --git a/include/media/videobuf-core.h b/include/media/videobuf-core.h index f2c41cebf453..f5eb2cbf3002 100644 --- a/include/media/videobuf-core.h +++ b/include/media/videobuf-core.h @@ -139,6 +139,7 @@ struct videobuf_qtype_ops { struct videobuf_queue { struct mutex vb_lock; + struct mutex *ext_lock; spinlock_t *irqlock; struct device *dev; @@ -167,6 +168,18 @@ struct videobuf_queue { void *priv_data; }; +static inline void videobuf_queue_lock(struct videobuf_queue *q) +{ + if (!q->ext_lock) + mutex_lock(&q->vb_lock); +} + +static inline void videobuf_queue_unlock(struct videobuf_queue *q) +{ + if (!q->ext_lock) + mutex_unlock(&q->vb_lock); +} + int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr); int videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb, struct v4l2_framebuffer *fbuf); -- cgit v1.2.3-59-g8ed1b