From patchwork Fri Jan 28 12:56:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 514701 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0SCvDqI012985 for ; Fri, 28 Jan 2011 12:57:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755002Ab1A1M5L (ORCPT ); Fri, 28 Jan 2011 07:57:11 -0500 Received: from mailout4.w1.samsung.com ([210.118.77.14]:24642 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752798Ab1A1M5K (ORCPT ); Fri, 28 Jan 2011 07:57:10 -0500 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: TEXT/PLAIN Received: from eu_spt1 ([210.118.77.14]) by mailout4.w1.samsung.com (Sun Java(tm) System Messaging Server 6.3-8.04 (built Jul 29 2009; 32bit)) with ESMTP id <0LFQ00E2PHB78090@mailout4.w1.samsung.com> for linux-media@vger.kernel.org; Fri, 28 Jan 2011 12:57:08 +0000 (GMT) Received: from linux.samsung.com ([106.116.38.10]) by spt1.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0LFQ00GEKHB77J@spt1.w1.samsung.com> for linux-media@vger.kernel.org; Fri, 28 Jan 2011 12:57:07 +0000 (GMT) Received: from mcdsrvbld02.digital.local (unknown [106.116.37.23]) by linux.samsung.com (Postfix) with ESMTP id 1EFD827004F; Fri, 28 Jan 2011 13:57:49 +0100 (CET) Date: Fri, 28 Jan 2011 13:56:39 +0100 From: Marek Szyprowski Subject: [PATCH 1/2] v4l2: vb2: fix queue reallocation and REQBUFS(0) case In-reply-to: <1296219400-2582-1-git-send-email-m.szyprowski@samsung.com> To: linux-media@vger.kernel.org Cc: m.szyprowski@samsung.com, pawel@osciak.com, kyungmin.park@samsung.com Message-id: <1296219400-2582-2-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.7.2.3 References: <1296219400-2582-1-git-send-email-m.szyprowski@samsung.com> 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 (demeter1.kernel.org [140.211.167.41]); Fri, 28 Jan 2011 12:57:13 +0000 (UTC) diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c index cc7ab0a..2f724ed 100644 --- a/drivers/media/video/videobuf2-core.c +++ b/drivers/media/video/videobuf2-core.c @@ -488,7 +488,7 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) return -EINVAL; } - if (req->count == 0 || q->num_buffers != 0) { + if (req->count == 0 || q->num_buffers != 0 || q->memory != req->memory) { /* * We already have buffers allocated, so first check if they * are not in use and can be freed. @@ -501,6 +501,13 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) ret = __vb2_queue_free(q); if (ret != 0) return ret; + + /* + * In case of REQBUFS(0) return immedietely without calling + * driver's queue_setup() callback and allocating resources. + */ + if (req->count == 0) + return 0; } /*