From patchwork Tue Oct 31 16:30:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 160222 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b90f:0:b0:403:3b70:6f57 with SMTP id t15csp365826vqg; Tue, 31 Oct 2023 09:36:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEwm44oYupcxAH7xtVmKHVs4qpAiJNG64FtbmrzG/46WptJlqRfec+WNP9W7gIl111qhnit X-Received: by 2002:a17:903:32cc:b0:1cc:4985:fc15 with SMTP id i12-20020a17090332cc00b001cc4985fc15mr8297346plr.27.1698770216098; Tue, 31 Oct 2023 09:36:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698770216; cv=none; d=google.com; s=arc-20160816; b=IQjkOTDIXVqbb5l7XspP4DbmjNxf2w0Y2GbCszIBB+k9Kn2VWxkYaan5Qha4o8TB/u 1LfVdPMSE1QJkXfPxRbXDm7MMT6NagNepiArClDtLMo6571iS3ezEriPAvV04vEzYqUp zMIVC8pmwvR9oZj+jjytdoZrtyxhH89DhOgCo5lkwcuWtAozq34qO9hitkjZRPIAReHq ihWmhZ7+aoks7gDsuntWorh4pBG35ovjQhdsADX6e5l1F07mk8QEDeD0oGW91a55Nj4y beos6CPTVbGx4fSMB7KF35EAPxxwEfedfsxt5lr8OJV91ng5wK5jfEruKuRo2HX/q50c NUIA== 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=cIauNEfyyc8ygY2CYOkqXtpUWGt5kjIwrFn6YVVwin8=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=zt4hyRBAWzZJcTUH4B7/4dEjay+Qs7nnCYVrE2pyVvzFk49S2qIjALQuV3Qk9bQjgN xJhhVeV6/tcWbxPPHoqwSI/GrHLN+cGGveae7mpSb3I53Iq8rRM/YmodvOMaPaK/BOmx vhvqvlk0kdI1CYncR5jxpJ0jawHSS92fdnFOG8BnzvIsfsb+U0ECncTkK3K6cgW1TIjQ 7CKxSEkDlpLp522cie4ZJoE2VjoZHIEPuFB0nyX7ONqkfa6pgECmoCrQcMeMS4ydLqUY r5VCOBqoUpzpw84haQs3txtUV6Ej/10hBSS7JrBNjIfpRyuLIdc7S1jUc706fDGtmirH mtsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=DpcRlo+g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id ku12-20020a17090b218c00b002791e648ceasi1158886pjb.112.2023.10.31.09.36.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 09:36:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=DpcRlo+g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 3B8B0804A62A; Tue, 31 Oct 2023 09:36:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346708AbjJaQgK (ORCPT + 33 others); Tue, 31 Oct 2023 12:36:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346498AbjJaQfS (ORCPT ); Tue, 31 Oct 2023 12:35:18 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10DF31FF5; Tue, 31 Oct 2023 09:32:36 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:c562:2ef4:80c0:92f]) (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 D589E66073CB; Tue, 31 Oct 2023 16:32:33 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1698769954; bh=KPoxd/SvOk21SjAKuo9XuAAvSFR2sEuxtH4tG5ksUhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DpcRlo+g4zRXEYOU+WftkbigSJXhl2DKpriogjse66Na81yCRc8ckOsxrJsuNqmsh ahmm4pnVx/ek+QMvXnX1zspZIlmexmrb+gTR78PgWsbEluJXieHA6XErfctUrMqwW2 hpx61fI7ObqfD48kfQFNCRIlS9/+QNjhvoTDFZnhRdiDkPZm3KWelD6Qr11ridmGFm BdmN7aXIizxfjWSCHN5KIsLOj57mBNjCqNc3tDIVd3mhY+TWwDRQyF0MUhDgVAmwJj 9cVhAk0tOXEpNb9jkPK9bv4rj9+ykcyEzACOUF1GQfTIXtGsDbFZ+L2U7BoYSygClV dLh3PLiXKnBjg== 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 v14 42/56] media: usb: usbtv: Stop direct calls to queue num_buffers field Date: Tue, 31 Oct 2023 17:30:50 +0100 Message-Id: <20231031163104.112469-43-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231031163104.112469-1-benjamin.gaignard@collabora.com> References: <20231031163104.112469-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Tue, 31 Oct 2023 09:36:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781289678271311692 X-GMAIL-MSGID: 1781289678271311692 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 Reviewed-by: Andrzej Pietrasiewicz --- drivers/media/usb/usbtv/usbtv-video.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c index 1e30e05953dc..62a583040cd4 100644 --- a/drivers/media/usb/usbtv/usbtv-video.c +++ b/drivers/media/usb/usbtv/usbtv-video.c @@ -726,9 +726,10 @@ static int usbtv_queue_setup(struct vb2_queue *vq, { struct usbtv *usbtv = vb2_get_drv_priv(vq); unsigned size = USBTV_CHUNK * usbtv->n_chunks * 2 * sizeof(u32); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); - if (vq->num_buffers + *nbuffers < 2) - *nbuffers = 2 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 2) + *nbuffers = 2 - q_num_bufs; if (*nplanes) return sizes[0] < size ? -EINVAL : 0; *nplanes = 1;