From patchwork Thu Oct 19 12:51:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 155528 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp360374vqb; Thu, 19 Oct 2023 05:56:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGfWprJpCm41+x860+rV9deq4NHNs7b6T1BN3WT7QaM2bfOF6S6rYOpM9dLS83Rt+RVbYDM X-Received: by 2002:a05:6808:280c:b0:3ac:a11a:4879 with SMTP id et12-20020a056808280c00b003aca11a4879mr1901470oib.39.1697720177003; Thu, 19 Oct 2023 05:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697720176; cv=none; d=google.com; s=arc-20160816; b=FW08Z573kty/3rkfKKsIEzteMXLoGYN33wWIWj+8pPsruYV4Z2mGC5F8Sy6jrMS7dj nt5cgdj2gUcNXPvHgb7b2t3yezpIuLS5CNga5RvojUzV41wCdQfU4S7wEUS3xu9kRJGY oJezqd31IJHdfw7zGvZZQZcvEaeZQMQYDXmEk8sPqubFQbZ+PzBMCfrnY8dCN9/7PEEL TC+I/6M8JpFnKtCUpQbQLwtaBqk8n7nReSmsCosXfzVwaLbXsEgvizMSJfv7kLuF/fzH ysX8LOSO4dZDDVIiSffGzYd1F+H1hO5LA71aydLJPMxe3VsVPe8aJ2oAWC2QGDgUHrmy v+ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qi0nDE9bMNN/N9JtsneH7OSkITzRhDazbSs/TwPJl7k=; fh=nyy6kl3x7bvRns0O2iGfKgaQnRSGFqx2aqkUiW72Nok=; b=agWBmvNNqhvmnEnLckntU/ZDfDhvSeKGbLiv7AoBovytGthvC4uM6e//Y/hOdRQm+w xDf5RYrgE1DF6BP2NFvYBppqsFsB+jFDvs0SbdcRCPOHwP34V0OmfxdMBwxVBkhjZ/z0 FTpTSbUycXrh1CAf7ci96W3O05i7iDvHcfR5konikgrEqR9H17XmK9o+D4cv5CDTYp1G XFSjBsolyN8pRoc/peSghAntlu6aIFL70XIvlooPdP6odfPTPbflauHfzvJqeW6xJy9a C3pSswCBfVqsoGpDrfj8HzcIGsmbO234sFOgBQ5uriT/GgP8H3h/o1BqRWLonO6O/oec eroQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="nzQY/3yH"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id n189-20020a6327c6000000b00565ec2a1e2asi4421476pgn.760.2023.10.19.05.56.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 05:56:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="nzQY/3yH"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id E796780F4E2A; Thu, 19 Oct 2023 05:56:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345891AbjJSMym (ORCPT + 25 others); Thu, 19 Oct 2023 08:54:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345840AbjJSMws (ORCPT ); Thu, 19 Oct 2023 08:52:48 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2E961A3; Thu, 19 Oct 2023 05:52:45 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:ccea:1fb5:34eb:239b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id 3099A660733B; Thu, 19 Oct 2023 13:52:44 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697719964; bh=QC82AXVc6xizeIJsB4Zdjgq5ICrOlS6NNBj04+AQSGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nzQY/3yHzKSqzUJ/818B/ENYDwEWXb655pNJKShse15WkbIBah45tDltRimhXDOXF FFioq7uxFmA0d6hPu9kCRES+odyRSa5DYsBqZTgfx9Di8kv9CuQd7GHdDzWfpLv4r1 yBrxjpXxhTBtwv2ADBTWvM/zhsKq14hELbsLn9dQ+G8030syc88oa/huHOH8T3O7Eq 6B9ESm9mdABUvtWaNw0vZoitj56FLQBeR8R/i2JBNFCzOyEKAizyyl/1zNoItuLMEm aeZf/AIzspP8ZOuxl1UM/8ERHd3GpdpiYxReKsHVsELRgbSTrJty2EGggxtswHr+k3 cUMcw8VBxTscQ== From: Benjamin Gaignard To: mchehab@kernel.org, tfiga@chromium.org, m.szyprowski@samsung.com, ming.qian@nxp.com, ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-staging@lists.linux.dev, kernel@collabora.com, Benjamin Gaignard , Matt Ranostay Subject: [PATCH v13 26/56] media: i2c: video-i2c: Stop direct calls to queue num_buffers field Date: Thu, 19 Oct 2023 14:51:52 +0200 Message-Id: <20231019125222.21370-27-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231019125222.21370-1-benjamin.gaignard@collabora.com> References: <20231019125222.21370-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 19 Oct 2023 05:56:06 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780188632271273379 X-GMAIL-MSGID: 1780188632271273379 Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. This allows us to change how the number of buffers is computed in the future. Signed-off-by: Benjamin Gaignard CC: Matt Ranostay --- drivers/media/i2c/video-i2c.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c index 178bd06cc2ed..ebf2ac98a068 100644 --- a/drivers/media/i2c/video-i2c.c +++ b/drivers/media/i2c/video-i2c.c @@ -405,9 +405,10 @@ static int queue_setup(struct vb2_queue *vq, { struct video_i2c_data *data = vb2_get_drv_priv(vq); unsigned int size = data->chip->buffer_size; + unsigned int q_num_bufs = vb2_get_num_buffers(vq); - if (vq->num_buffers + *nbuffers < 2) - *nbuffers = 2; + if (q_num_bufs + *nbuffers < 2) + *nbuffers = 2 - q_num_bufs; if (*nplanes) return sizes[0] < size ? -EINVAL : 0;