From patchwork Tue Oct 3 08:06: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: 147736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1930040vqb; Tue, 3 Oct 2023 01:11:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFEHkdT5Vp5I4/4V6aidWTetZcc7kJzGNpmWoZy8Qhg9ZVTQCinnFaBUTwGDBQjVkaT07rk X-Received: by 2002:a17:90b:3781:b0:26d:d81:82fb with SMTP id mz1-20020a17090b378100b0026d0d8182fbmr10494712pjb.29.1696320716533; Tue, 03 Oct 2023 01:11:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320716; cv=none; d=google.com; s=arc-20160816; b=uKhEuHRaww2xmNjYAOtDy68FDFT7YE9OlKuFC9IfTB+ByuwB4uCbsuqIRyBWZgYpP2 f1A7wtwVHXnUStq2vb4jwQpA6rxdtRmM+r9u8r+iuJlmWYpbf58IMXEj6BXIuFeONvjq mvmOyp87Ao0MF4JpiboDj0cDkXRf6I9Or9Fz4Onn+ZC8UUfl6ueIBopu7RX3MUdX6J7O bBDCEYWQGSS72NRNIM7ndgzHqbOpZv2jHvGyX7dn55lQ/9ngbaBjM6sx+3O3CHVIAx5P afCfNSYDm0oF1/uOQeO6nkumqV83HLeeH1sol8OdRbND6R5/dj/hHEv1nwCYDtqLXtfz 5kcQ== 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=J/AixmhINWwllXoUE6TaGJLLvNPmGkjrDHeZV6N6Jrg=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=I9kHQN9yIH25QAMmHWrN/PgSe7WBandXT0OpuMdnhO1gf+pU2JvmIPVef/vGx4F5vD OzCKREM50OdRKpnI8ob+He8GlP52Z7onLAa3wNMkvVcRtr0npowEEE6oyGhERVRX416F DeF86E7vWkt/80eczdilWImQDy9HCZn9K73YfVHwaO2Z/L38+Oz2trvw5UXpoCEfUMZo QpzsH/0aufyEB1Fr8mHWCjnU3VizowSgeH+l7pmmn7j5Zr3fdhxHrJTT566nM6yjf3Am qCyzCk6w/PwwXf0fD1Sa6Atcyr4ZLG4lNkCdSnFCTsRlTKfd1TGabZMv9i3IBLlsDhmm sBIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=G0D2D57C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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. [23.128.96.34]) by mx.google.com with ESMTPS id w184-20020a6382c1000000b005777c70ebfbsi920846pgd.612.2023.10.03.01.11.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:11:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=G0D2D57C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 D1584806E56A; Tue, 3 Oct 2023 01:10:49 -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 S239790AbjJCIKY (ORCPT + 18 others); Tue, 3 Oct 2023 04:10:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239545AbjJCIHr (ORCPT ); Tue, 3 Oct 2023 04:07:47 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3444BFF; Tue, 3 Oct 2023 01:07:37 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 4A6A4660735A; Tue, 3 Oct 2023 09:07:35 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320455; bh=bradh2DjPo+ZZEdsMUYFEpcwZsisivarvW4Ps2cAzgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G0D2D57CrGK1Vq6Jq3MCmxNDB3FLxQo+v75pWD0P0s3SCtGQUQcxEk9usaKmnDiys gSF2R3qROSVKa4G3IT6cdmCDuVcqzHumgPwCYUCZDXQ7v6IH4gyoPcJcxtNWZn8rTY kEB5lY0+on/qdl8+1CvBWeyqYJsAxMbpSPfrit0OSoxgLWqhg2JMgEX4CVLDrb7ZQs Y1ve9v38b4WmErZeO3BOjZS4TVBKvf2O83U4Cnve8g8CuuhRxXoqFmob4H5+tqtI/K l7B/Bl+AOo13I56EKpTlbxs3hOLHHilPqu3OryGEEFKLOHQ2hHJdGAFsRv+Vegk9PA ViiWuDk4JHlPA== 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 Subject: [PATCH v10 43/54] media: imx: Stop direct calls to queue num_buffers field Date: Tue, 3 Oct 2023 10:06:52 +0200 Message-Id: <20231003080704.43911-44-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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]); Tue, 03 Oct 2023 01:10:49 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721191767176319 X-GMAIL-MSGID: 1778721191767176319 Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. Signed-off-by: Benjamin Gaignard --- drivers/staging/media/imx/imx-media-capture.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c index 4846078315ff..ce02199e7b1b 100644 --- a/drivers/staging/media/imx/imx-media-capture.c +++ b/drivers/staging/media/imx/imx-media-capture.c @@ -605,6 +605,7 @@ static int capture_queue_setup(struct vb2_queue *vq, { struct capture_priv *priv = vb2_get_drv_priv(vq); struct v4l2_pix_format *pix = &priv->vdev.fmt; + unsigned int q_num_bufs = vb2_get_num_buffers(vq); unsigned int count = *nbuffers; if (vq->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) @@ -613,14 +614,14 @@ static int capture_queue_setup(struct vb2_queue *vq, if (*nplanes) { if (*nplanes != 1 || sizes[0] < pix->sizeimage) return -EINVAL; - count += vq->num_buffers; + count += q_num_bufs; } count = min_t(__u32, VID_MEM_LIMIT / pix->sizeimage, count); if (*nplanes) - *nbuffers = (count < vq->num_buffers) ? 0 : - count - vq->num_buffers; + *nbuffers = (count < q_num_bufs) ? 0 : + count - q_num_bufs; else *nbuffers = count;