From patchwork Tue May 10 13:49:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Farnsworth X-Patchwork-Id: 774362 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4ADo43G002742 for ; Tue, 10 May 2011 13:50:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756305Ab1EJNuB (ORCPT ); Tue, 10 May 2011 09:50:01 -0400 Received: from claranet-outbound-smtp00.uk.clara.net ([195.8.89.33]:55351 "EHLO claranet-outbound-smtp00.uk.clara.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755258Ab1EJNuA (ORCPT ); Tue, 10 May 2011 09:50:00 -0400 Received: from 110.100.155.90.in-addr.arpa ([90.155.100.110]:47821 helo=f12simon.office.onelan.co.uk) by relay00.mail.eu.clara.net (relay.clara.net [213.253.3.40]:1025) with esmtpa (authdaemon_plain:simon.farnsworth@onelan.co.uk) id 1QJnJy-0005CE-0j (return-path ); Tue, 10 May 2011 13:49:54 +0000 From: Simon Farnsworth To: Mauro Carvalho Chehab Cc: Andy Walls , Hans Verkuil , linux-media@vger.kernel.org, Steven Toth , Simon Farnsworth Subject: [PATCH] cx18: Move spinlock and vb_type initialisation into stream_init Date: Tue, 10 May 2011 14:49:50 +0100 Message-Id: <1305035390-31439-1-git-send-email-simon.farnsworth@onelan.co.uk> X-Mailer: git-send-email 1.7.4 In-Reply-To: <4DC2A8FD.4010902@infradead.org> References: <4DC2A8FD.4010902@infradead.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 10 May 2011 13:50:05 +0000 (UTC) The initialisation of vb_type in serialized_open was preventing REQBUFS from working reliably. Remove it, and move the spinlock into stream_init for good measure - it's only used when we have a stream that supports videobuf anyway. Signed-off-by: Simon Farnsworth --- Mauro, This fixes a bug I introduced, and noticed while trying to work out how videobuf works and interacts with the rest of the driver, in preparation for working out how to port this code to videobuf2. Briefly, if you open a device node at the wrong time, you lose videobuf support forever. Please consider this for 2.6.40, Simon drivers/media/video/cx18/cx18-fileops.c | 3 --- drivers/media/video/cx18/cx18-streams.c | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/media/video/cx18/cx18-fileops.c b/drivers/media/video/cx18/cx18-fileops.c index 6609222..07411f3 100644 --- a/drivers/media/video/cx18/cx18-fileops.c +++ b/drivers/media/video/cx18/cx18-fileops.c @@ -810,9 +810,6 @@ static int cx18_serialized_open(struct cx18_stream *s, struct file *filp) item->cx = cx; item->type = s->type; - spin_lock_init(&s->vbuf_q_lock); - s->vb_type = 0; - item->open_id = cx->open_id++; filp->private_data = &item->fh; diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c index 24c9688..4282ff5 100644 --- a/drivers/media/video/cx18/cx18-streams.c +++ b/drivers/media/video/cx18/cx18-streams.c @@ -275,6 +275,8 @@ static void cx18_stream_init(struct cx18 *cx, int type) init_timer(&s->vb_timeout); spin_lock_init(&s->vb_lock); if (type == CX18_ENC_STREAM_TYPE_YUV) { + spin_lock_init(&s->vbuf_q_lock); + s->vb_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; videobuf_queue_vmalloc_init(&s->vbuf_q, &cx18_videobuf_qops, &cx->pci_dev->dev, &s->vbuf_q_lock,