From patchwork Thu Nov 9 16:34:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 163485 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp559073vqs; Thu, 9 Nov 2023 08:39:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IHOqlfmXLY+Ve7bvFcDTfqwEEEUjvoqyBZ2HBrt+yl4Ke/W+yCcb4noW1VQH5G4i8Lmq/HL X-Received: by 2002:a05:6a00:4516:b0:6c3:4135:d1da with SMTP id cw22-20020a056a00451600b006c34135d1damr9616959pfb.1.1699547951381; Thu, 09 Nov 2023 08:39:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699547951; cv=none; d=google.com; s=arc-20160816; b=cJH50lmE92MphYDOZ6JLIclsuf649tB7WcvpCBZxTLJh62baZ+cS8LVRMjFfZPf7WK r470MOTkUGa3vDFhdxMq+S6SAdrLiGC5/spXHIrksQlWcZphLBPqAvvo+rM4SusIAsGJ UdpiW2Hv8HY/0hLkNCc+mrxzB3fwTn09LKHCuq3mjGPxKz+87OplLkEXzJL3LjpxP62b EStiaR+P1PL5wnfRC9tKGo7QyqmVgMXeK+k+3lLIKqSI0e27yKxLK40vs6KBAFKxtmaJ /HzbOeWuug319ANlDlEcr6WiN2KHUHbCXm+xPh34zeyqZ3q7WG1xKfawgNwaS78HIePi hpew== 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=dMIENpW9bIqDtz1yUAzj/PQ4uorLGeO1rhwXyk2WxLM=; fh=nyy6kl3x7bvRns0O2iGfKgaQnRSGFqx2aqkUiW72Nok=; b=NJrkw6jfXSWSk3hzJLTfQa466Tk/WCYbpAdwbQZGxs7EWVyyLgx/c+09/Jau5b1zHy ieDEAlKHZ+DtdsWHOnlJjQhNKVdSWIdVOnyVT1P/Edhzg4YFELPav8es3ufy8YZVIcrZ a+42QVMoMiqG1KIFeuVdsbxYeP4SQeFXjwU2IY1DhZUOeAm9V9eyKkI973kY0bdbGr0J AfpTS+qNuNAvVFeWH6urBxbxibjyx5ajOEqa5NWQLVO+XzdfiZgcpEN0ei8nG6I6AamE ssBz5IU2KcQGWSiZhSzBEBtIWzPZoUPciX8qegEv3F8qIiQIAdqAQ7r2aNDNChCBt49I z46w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=kGCyS5dg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id s20-20020a056a00195400b006c3535bfc83si16727747pfk.15.2023.11.09.08.39.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 08:39:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=kGCyS5dg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 8E724837C49E; Thu, 9 Nov 2023 08:39:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234816AbjKIQip (ORCPT + 31 others); Thu, 9 Nov 2023 11:38:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344717AbjKIQiO (ORCPT ); Thu, 9 Nov 2023 11:38:14 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B83003AB5; Thu, 9 Nov 2023 08:38:01 -0800 (PST) Received: from benjamin-XPS-13-9310.. (cola.collaboradmins.com [195.201.22.229]) (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 B06E9660740E; Thu, 9 Nov 2023 16:37:59 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1699547880; bh=U1yXDNk7EDltAc7ujIBPx5Id4Pnzi9DFGv3btwrQ75o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kGCyS5dgMfwq/IjrQdpOVgWr+gd+odSozOhTYVbDwedj0NpvjWG4FUf//X7mDizGd M2+CBjRZSX4W/R7VMo9uyovrEBukbxev5N9r7ovZgqdIgLLqaLysQG5BkPfLBB+vRT l2TEa5xJFvDdfnqeGrV6N6Zh/3fMC640uoD0tvl/MTy4fzNNiVjeM7uQGuYmJ7L42B mY/fOyWDFSPWKkNwe1tgkCgmtNFj6mzOKCVdhyXEISt0OttFouoy38arcuh4smHWy9 zC/LHfhjMkVvag7IC3pf3HiEK2Iq+vRQEGwwpHbNKqRjrpG39ehHKfSWiO1WkT0v7D a/RqPi5No2H4g== 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 v15 26/56] media: i2c: video-i2c: Stop direct calls to queue num_buffers field Date: Thu, 9 Nov 2023 17:34:42 +0100 Message-Id: <20231109163512.179524-27-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231109163512.179524-14-benjamin.gaignard@collabora.com> References: <20231109163512.179524-14-benjamin.gaignard@collabora.com> MIME-Version: 1.0 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 (snail.vger.email [0.0.0.0]); Thu, 09 Nov 2023 08:39:09 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782105192471394865 X-GMAIL-MSGID: 1782105192471394865 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. Fix the number of buffers computation at the same time. Signed-off-by: Benjamin Gaignard CC: Matt Ranostay Reviewed-by: Andrzej Pietrasiewicz --- 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;