[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <be16b724-a8fb-4928-bff6-d95e1224bd20@collabora.com>
Date: Wed, 8 Nov 2023 17:55:14 +0100
From: Andrzej Pietrasiewicz <andrzej.p@...labora.com>
To: Benjamin Gaignard <benjamin.gaignard@...labora.com>,
mchehab@...nel.org, tfiga@...omium.org, m.szyprowski@...sung.com,
ming.qian@....com, ezequiel@...guardiasur.com.ar,
p.zabel@...gutronix.de, gregkh@...uxfoundation.org,
hverkuil-cisco@...all.nl, nicolas.dufresne@...labora.com
Cc: linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org, linux-arm-msm@...r.kernel.org,
linux-rockchip@...ts.infradead.org, linux-staging@...ts.linux.dev,
kernel@...labora.com, Zhou Peng <eagle.zhou@....com>
Subject: Re: [PATCH v14 09/56] media: amphion: Use vb2_get_buffer() instead of
directly access to buffers array
W dniu 31.10.2023 o 17:30, Benjamin Gaignard pisze:
> Use vb2_get_buffer() instead of direct access to the vb2_queue bufs array.
> This allows us to change the type of the bufs in the future.
> 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@...labora.com>
Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@...labora.com>
> CC: Ming Qian <ming.qian@....com>
> CC: Zhou Peng <eagle.zhou@....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],
Powered by blists - more mailing lists