From b0426b9d38d42bfbcf51adbb88581be51dac0b8a Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 26 Apr 2008 14:52:53 -0300 Subject: videobuf-core: backport brandon's patch From: Mauro Carvalho Chehab I and Brandon did similar patches. As Brandon patch where older, I've preserved his patch at -git. However, the patches weren't equal. kernel-sync: Signed-off-by: Mauro Carvalho Chehab --- linux/drivers/media/video/videobuf-core.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'linux/drivers/media/video/videobuf-core.c') diff --git a/linux/drivers/media/video/videobuf-core.c b/linux/drivers/media/video/videobuf-core.c index 367f150a9..6e82dbb65 100644 --- a/linux/drivers/media/video/videobuf-core.c +++ b/linux/drivers/media/video/videobuf-core.c @@ -131,12 +131,12 @@ void videobuf_queue_core_init(struct videobuf_queue *q, BUG_ON(!q->ops->buf_queue); BUG_ON(!q->ops->buf_release); + /* Lock is mandatory for queue_cancel to work */ + BUG_ON(!irqlock); + /* Having implementations for abstract methods are mandatory */ BUG_ON(!q->int_ops); - /* Having irqlock is mandatory */ - BUG_ON(!q->irqlock); - mutex_init(&q->vb_lock); init_waitqueue_head(&q->wait); INIT_LIST_HEAD(&q->stream); @@ -759,7 +759,6 @@ static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q, spin_lock_irqsave(q->irqlock, flags); q->ops->buf_queue(q, q->read_buf); spin_unlock_irqrestore(q->irqlock, flags); - retval = videobuf_waiton(q->read_buf, 0, 0); if (0 == retval) { CALL(q, sync, q, q->read_buf); @@ -820,6 +819,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q, q->read_buf = NULL; goto done; } + spin_lock_irqsave(q->irqlock, flags); q->ops->buf_queue(q, q->read_buf); spin_unlock_irqrestore(q->irqlock, flags); @@ -889,12 +889,10 @@ static int __videobuf_read_start(struct videobuf_queue *q) return err; list_add_tail(&q->bufs[i]->stream, &q->stream); } - spin_lock_irqsave(q->irqlock, flags); for (i = 0; i < count; i++) q->ops->buf_queue(q, q->bufs[i]); spin_unlock_irqrestore(q->irqlock, flags); - q->reading = 1; return 0; } @@ -1006,11 +1004,9 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q, if (q->read_off == q->read_buf->size) { list_add_tail(&q->read_buf->stream, &q->stream); - spin_lock_irqsave(q->irqlock, flags); q->ops->buf_queue(q, q->read_buf); spin_unlock_irqrestore(q->irqlock, flags); - q->read_buf = NULL; } if (retval < 0) -- cgit v1.2.3