From: Benjamin Gaignard <benjamin.gaignard@collabora.com>
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 <benjamin.gaignard@collabora.com>
Subject: [PATCH v6 04/18] media: amphion: Use vb2_get_buffer() instead of directly access to buffers array
Date: Fri, 1 Sep 2023 14:44:00 +0200 [thread overview]
Message-ID: <20230901124414.48497-5-benjamin.gaignard@collabora.com> (raw)
In-Reply-To: <20230901124414.48497-1-benjamin.gaignard@collabora.com>
Use vb2_get_buffer() instead of directly access to vb2_buffer buffer array.
This could allow to change the type bufs[] field of vb2_buffer structure if
needed.
After each call to vb2_get_buffer() we need to be sure that we get
a valid pointer so check the return value of all of them.
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
---
drivers/media/platform/amphion/vpu_dbg.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/drivers/media/platform/amphion/vpu_dbg.c b/drivers/media/platform/amphion/vpu_dbg.c
index 982c2c777484..a462d6fe4ea9 100644
--- a/drivers/media/platform/amphion/vpu_dbg.c
+++ b/drivers/media/platform/amphion/vpu_dbg.c
@@ -140,11 +140,18 @@ static int vpu_dbg_instance(struct seq_file *s, void *data)
vq = v4l2_m2m_get_src_vq(inst->fh.m2m_ctx);
for (i = 0; i < vq->num_buffers; i++) {
- struct vb2_buffer *vb = vq->bufs[i];
- struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
+ struct vb2_buffer *vb;
+ struct vb2_v4l2_buffer *vbuf;
+
+ vb = vb2_get_buffer(vq, i);
+ if (!vb)
+ continue;
if (vb->state == VB2_BUF_STATE_DEQUEUED)
continue;
+
+ vbuf = to_vb2_v4l2_buffer(vb);
+
num = scnprintf(str, sizeof(str),
"output [%2d] state = %10s, %8s\n",
i, vb2_stat_name[vb->state],
@@ -155,11 +162,18 @@ static int vpu_dbg_instance(struct seq_file *s, void *data)
vq = v4l2_m2m_get_dst_vq(inst->fh.m2m_ctx);
for (i = 0; i < vq->num_buffers; i++) {
- struct vb2_buffer *vb = vq->bufs[i];
- struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
+ struct vb2_buffer *vb;
+ struct vb2_v4l2_buffer *vbuf;
+
+ vb = vb2_get_buffer(vq, i);
+ if (!vb)
+ continue;
if (vb->state == VB2_BUF_STATE_DEQUEUED)
continue;
+
+ vbuf = to_vb2_v4l2_buffer(vb);
+
num = scnprintf(str, sizeof(str),
"capture[%2d] state = %10s, %8s\n",
i, vb2_stat_name[vb->state],
--
2.39.2
next prev parent reply other threads:[~2023-09-01 12:44 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-01 12:43 [PATCH v6 00/18] Add DELETE_BUF ioctl Benjamin Gaignard
2023-09-01 12:43 ` [PATCH v6 01/18] media: videobuf2: Rework offset 'cookie' encoding pattern Benjamin Gaignard
2023-09-01 12:43 ` [PATCH v6 02/18] media: videobuf2: Stop spamming kernel log with all queue counter Benjamin Gaignard
2023-09-04 15:17 ` Hans Verkuil
2023-09-01 12:43 ` [PATCH v6 03/18] media: videobuf2: Use vb2_buffer instead of index Benjamin Gaignard
2023-09-01 12:44 ` Benjamin Gaignard [this message]
2023-09-01 12:44 ` [PATCH v6 05/18] media: mediatek: jpeg: Use vb2_get_buffer() instead of directly access to buffers array Benjamin Gaignard
2023-09-01 12:44 ` [PATCH v6 06/18] media: mediatek: vdec: " Benjamin Gaignard
2023-09-01 12:44 ` [PATCH v6 07/18] media: sti: hva: " Benjamin Gaignard
2023-09-01 12:44 ` [PATCH v6 08/18] media: visl: " Benjamin Gaignard
2023-09-01 12:44 ` [PATCH v6 09/18] media: atomisp: " Benjamin Gaignard
2023-09-01 12:44 ` [PATCH v6 10/18] media: videobuf2: Access vb2_queue bufs array through helper functions Benjamin Gaignard
2023-09-01 12:44 ` [PATCH v6 11/18] media: videobuf2: Be more flexible on the number of queue stored buffers Benjamin Gaignard
2023-09-04 11:24 ` Hans Verkuil
2023-09-04 11:46 ` Benjamin Gaignard
2023-09-04 14:09 ` Hans Verkuil
2023-09-04 15:05 ` Hans Verkuil
2023-09-04 15:19 ` Hans Verkuil
2023-09-01 12:44 ` [PATCH v6 12/18] media: verisilicon: Refactor postprocessor to store more buffers Benjamin Gaignard
2023-09-01 12:44 ` [PATCH v6 13/18] media: verisilicon: Store chroma and motion vectors offset Benjamin Gaignard
2023-09-01 12:44 ` [PATCH v6 14/18] media: verisilicon: vp9: Use destination buffer height to compute chroma offset Benjamin Gaignard
2023-09-10 13:21 ` Jernej Škrabec
2023-09-11 8:55 ` Benjamin Gaignard
2023-09-11 16:36 ` Jernej Škrabec
2023-09-12 8:41 ` Benjamin Gaignard
2023-09-12 15:26 ` Nicolas Dufresne
2023-09-12 15:51 ` Jernej Škrabec
2023-09-01 12:44 ` [PATCH v6 15/18] media: verisilicon: postproc: Fix down scale test Benjamin Gaignard
2023-09-01 12:44 ` [PATCH v6 16/18] media: verisilicon: vp9: Allow to change resolution while streaming Benjamin Gaignard
2023-09-01 12:44 ` [PATCH v6 17/18] media: v4l2: Add DELETE_BUFS ioctl Benjamin Gaignard
2023-09-05 8:17 ` Hans Verkuil
2023-09-05 8:43 ` Hans Verkuil
2023-09-05 14:28 ` Benjamin Gaignard
2023-09-05 14:37 ` Hans Verkuil
2023-09-01 12:44 ` [PATCH v6 18/18] media: v4l2: Add mem2mem helpers for " Benjamin Gaignard
2023-09-04 15:23 ` [PATCH v6 00/18] Add DELETE_BUF ioctl Hans Verkuil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230901124414.48497-5-benjamin.gaignard@collabora.com \
--to=benjamin.gaignard@collabora.com \
--cc=ezequiel@vanguardiasur.com.ar \
--cc=gregkh@linuxfoundation.org \
--cc=hverkuil-cisco@xs4all.nl \
--cc=kernel@collabora.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-staging@lists.linux.dev \
--cc=m.szyprowski@samsung.com \
--cc=mchehab@kernel.org \
--cc=ming.qian@nxp.com \
--cc=nicolas.dufresne@collabora.com \
--cc=p.zabel@pengutronix.de \
--cc=tfiga@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox