Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp249493rdg; Thu, 12 Oct 2023 04:52:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEUvnJKmx3LnKYqAnSE9bGiYJ6vQgAPMN95ROBp7L4czbxi8hZxALHqI6totQeCx6rq17sU X-Received: by 2002:a05:6a20:3d02:b0:13d:1d14:6693 with SMTP id y2-20020a056a203d0200b0013d1d146693mr25385713pzi.45.1697111524000; Thu, 12 Oct 2023 04:52:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111523; cv=none; d=google.com; s=arc-20160816; b=WwGS4nEmkwBelPUK2MPVy4cIBEbxJGnARg/MxRCu7NTrYiHgjGs9GsiJw6AjJnuMxD ZYBwzAPQkvy+x2r4SNFjRE8f/FRhnVgFWwFU/osx4kJbG1C1tUE3/Qwkb++IDvyDSSN/ 7vTKfG00v80ZuqOxw6lU+y/QhmmYjnkGXdJZqXPW+StFoSxvX4kJGubbuhwk3ZtjsQrk OsEDAUphQ6o/FOUfH8Rj0An7ZMYMyxvjCJTl9+LpsEhLo/YuEPIWhCR3f5physK6sE8i WRZuh73fhb/kgH/dxYDBfh01sbQ79caS1LyK6CGk5qyjVoYBTZADMAcYq1UkvJdIZNB7 R0Hw== 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=362WKbueytuHEGcwCkpvyPQdlAvKGzTlZTHPMJDeEK0=; fh=XOQPNehgv2/6iNwDVzIYzJa3sauUpivvTAZ7odRKM4M=; b=lWooesvFDZPhR2iO6DlPx1+g6pjRogI0BZgvfxQqnC4n9eASB0tiU6in273zQN73Vx 7uaDvglLGLtHyulma9+PgBxfNYEbz+PqbpHGS/Nm0PhjsvK/uF/gR/i3L+ug6a9gfsyT H310LBrN/Ay8qnfkWhDG+wE77AshJsQpAH6SLys5p6P+mIX1X8yJ4OiMj/d9CBMjbaXM k7mZveJO6zVMS69FYt7dUaBZcsGD9h5ln2d1Az+d4MU3fe5EcIgpwkIhryWaAp03kOJJ bedv8EevxCnQiI1gJeELA+nndi+sOQjK0IyBTdzF1XjTLv5Fyk9O/AyNsEzIQmufApww 2GPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hUw3QnNY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id mj11-20020a17090b368b00b002747b95c23bsi2114635pjb.110.2023.10.12.04.52.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:52:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hUw3QnNY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id E02FC8077810; Thu, 12 Oct 2023 04:51:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379301AbjJLLtm (ORCPT + 99 others); Thu, 12 Oct 2023 07:49:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378958AbjJLLrd (ORCPT ); Thu, 12 Oct 2023 07:47:33 -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 ED766C4; Thu, 12 Oct 2023 04:47:12 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 3B5AF660739E; Thu, 12 Oct 2023 12:47:11 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111231; bh=jcGjQtwVZXm/63GKjgXKs2SZ3PMRIqgDfC2W6RW1MBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hUw3QnNYwlyaE6Ckbn5bcMVNybTrPj/hvxoTs5pGfX4Izeh0pkb2QsbUu7Z00U1p8 STjuKlaZDCUmdVgjAvhvRznkEjFw7H9wyQntvY1DRS5PoFX+dcnNmhxMGOTwp3vVJO n0Of2tqIBcemUrFFVI48DiTCV4GWOhaDaw5B/X/cdvpS0D+heq3d7J8KCtkOQXnyQ1 Zpzej9wBc9pRO1+IcVcTsEStnucuC4XzCaQk8NEztBe2Q0ERVYTy2zgI1tSFk7kSNh iVBni6QZL+lAampGQ5FHe8K/+VR2irTZeC7ss110pUnWh06FP0Zvld+5wFYPvmkcLV 5SMLdxzTHP0JQ== 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 , Maxime Ripard , Paul Kocialkowski Subject: [PATCH v11 41/56] media: cedrus: Stop direct calls to queue num_buffers field Date: Thu, 12 Oct 2023 13:46:27 +0200 Message-Id: <20231012114642.19040-42-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 fry.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 (fry.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:51:10 -0700 (PDT) Use vb2_get_num_buffers() and queue max_num_buffers field to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard CC: Maxime Ripard CC: Paul Kocialkowski --- drivers/staging/media/sunxi/cedrus/cedrus_h264.c | 8 ++++++-- drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c index dfb401df138a..95e490532a87 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c @@ -653,8 +653,12 @@ static void cedrus_h264_stop(struct cedrus_ctx *ctx) vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); - for (i = 0; i < vq->num_buffers; i++) { - buf = vb2_to_cedrus_buffer(vb2_get_buffer(vq, i)); + for (i = 0; i < vb2_get_num_buffers(vq); i++) { + struct vb2_buffer *vb = vb2_get_buffer(vq, i); + + if (!vb) + continue; + buf = vb2_to_cedrus_buffer(vb); if (buf->codec.h264.mv_col_buf_size > 0) { dma_free_attrs(dev->dev, diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c index fc9297232456..52e94c8f2f01 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c @@ -869,8 +869,13 @@ static void cedrus_h265_stop(struct cedrus_ctx *ctx) vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); - for (i = 0; i < vq->num_buffers; i++) { - buf = vb2_to_cedrus_buffer(vb2_get_buffer(vq, i)); + for (i = 0; i < vb2_get_num_buffers(vq); i++) { + struct vb2_buffer *vb = vb2_get_buffer(vq, i); + + if (!vb) + continue; + + buf = vb2_to_cedrus_buffer(vb); if (buf->codec.h265.mv_col_buf_size > 0) { dma_free_attrs(dev->dev, -- 2.39.2