[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d52bff95-7cee-4e75-9f77-488384e92998@xs4all.nl>
Date: Tue, 19 Sep 2023 16:19:27 +0200
From: Hans Verkuil <hverkuil-cisco@...all.nl>
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,
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
Subject: Re: [PATCH v7 38/49] media: usb: cx231xx: Stop direct calls to queue
num_buffers field
On 14/09/2023 15:33, Benjamin Gaignard wrote:
> Use vb2_get_num_buffers() to avoid using queue num_buffer field directly.
>
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@...labora.com>
> ---
> drivers/media/usb/cx231xx/cx231xx-417.c | 5 +++--
> drivers/media/usb/cx231xx/cx231xx-video.c | 5 +++--
> 2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c
> index c5e21785fafe..9ec0b7e355e2 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-417.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-417.c
> @@ -1218,13 +1218,14 @@ static int queue_setup(struct vb2_queue *vq,
> unsigned int sizes[], struct device *alloc_devs[])
> {
> struct cx231xx *dev = vb2_get_drv_priv(vq);
> + unsigned int q_num_bufs = vb2_get_num_buffers(vq);
> unsigned int size = mpeglinesize * mpeglines;
>
> dev->ts1.ts_packet_size = mpeglinesize;
> dev->ts1.ts_packet_count = mpeglines;
>
> - if (vq->num_buffers + *nbuffers < CX231XX_MIN_BUF)
> - *nbuffers = CX231XX_MIN_BUF - vq->num_buffers;
> + if (q_num_bufs + *nbuffers < CX231XX_MIN_BUF)
> + *nbuffers = CX231XX_MIN_BUF - q_num_bufs;
Drop the check, update min_buffers_needed from 1 to CX231XX_MIN_BUF.
>
> if (*nplanes)
> return sizes[0] < size ? -EINVAL : 0;
> diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
> index e23b8ccd79d4..c8eb4222319d 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-video.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-video.c
> @@ -714,11 +714,12 @@ static int queue_setup(struct vb2_queue *vq,
> unsigned int sizes[], struct device *alloc_devs[])
> {
> struct cx231xx *dev = vb2_get_drv_priv(vq);
> + unsigned int q_num_bufs = vb2_get_num_buffers(vq);
>
> dev->size = (dev->width * dev->height * dev->format->depth + 7) >> 3;
>
> - if (vq->num_buffers + *nbuffers < CX231XX_MIN_BUF)
> - *nbuffers = CX231XX_MIN_BUF - vq->num_buffers;
> + if (q_num_bufs + *nbuffers < CX231XX_MIN_BUF)
> + *nbuffers = CX231XX_MIN_BUF - q_num_bufs;
Ditto.
>
> if (*nplanes)
> return sizes[0] < dev->size ? -EINVAL : 0;
Regards,
Hans
Powered by blists - more mailing lists