diff mbox series

[v2] media: media videobuf2: Stop direct calls to queue num_buffers field

Message ID 20240118121452.29151-1-benjamin.gaignard@collabora.com (mailing list archive)
State New, archived
Headers show
Series [v2] media: media videobuf2: Stop direct calls to queue num_buffers field | expand

Commit Message

Benjamin Gaignard Jan. 18, 2024, 12:14 p.m. UTC
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 <benjamin.gaignard@collabora.com>
---
version 2:
- Change vdev->queue->num_buffers to vb2_get_num_buffers(vdev->queue)
  in vb2_ioctl_create_bufs().
- Remove Fixes tag

 drivers/media/common/videobuf2/videobuf2-core.c | 2 +-
 drivers/media/common/videobuf2/videobuf2-v4l2.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Tomasz Figa Jan. 18, 2024, 12:44 p.m. UTC | #1
On Thu, Jan 18, 2024 at 9:15 PM Benjamin Gaignard
<benjamin.gaignard@collabora.com> wrote:
>
> 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 <benjamin.gaignard@collabora.com>
> ---
> version 2:
> - Change vdev->queue->num_buffers to vb2_get_num_buffers(vdev->queue)
>   in vb2_ioctl_create_bufs().
> - Remove Fixes tag
>
>  drivers/media/common/videobuf2/videobuf2-core.c | 2 +-
>  drivers/media/common/videobuf2/videobuf2-v4l2.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
> index 41a832dd1426..b6bf8f232f48 100644
> --- a/drivers/media/common/videobuf2/videobuf2-core.c
> +++ b/drivers/media/common/videobuf2/videobuf2-core.c
> @@ -989,7 +989,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
>         bool no_previous_buffers = !q_num_bufs;
>         int ret = 0;
>
> -       if (q->num_buffers == q->max_num_buffers) {
> +       if (q_num_bufs == q->max_num_buffers) {
>                 dprintk(q, 1, "maximum number of buffers already allocated\n");
>                 return -ENOBUFS;
>         }
> diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c
> index 54d572c3b515..6380155d8575 100644
> --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
> +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
> @@ -1029,7 +1029,7 @@ int vb2_ioctl_create_bufs(struct file *file, void *priv,
>         int res = vb2_verify_memory_type(vdev->queue, p->memory,
>                         p->format.type);
>
> -       p->index = vdev->queue->num_buffers;
> +       p->index = vb2_get_num_buffers(vdev->queue);
>         fill_buf_caps(vdev->queue, &p->capabilities);
>         validate_memory_flags(vdev->queue, p->memory, &p->flags);
>         /*
> --
> 2.40.1
>

Acked-by: Tomasz Figa <tfiga@chromium.org>

Best regards,
Tomasz
diff mbox series

Patch

diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
index 41a832dd1426..b6bf8f232f48 100644
--- a/drivers/media/common/videobuf2/videobuf2-core.c
+++ b/drivers/media/common/videobuf2/videobuf2-core.c
@@ -989,7 +989,7 @@  int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
 	bool no_previous_buffers = !q_num_bufs;
 	int ret = 0;
 
-	if (q->num_buffers == q->max_num_buffers) {
+	if (q_num_bufs == q->max_num_buffers) {
 		dprintk(q, 1, "maximum number of buffers already allocated\n");
 		return -ENOBUFS;
 	}
diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c
index 54d572c3b515..6380155d8575 100644
--- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
+++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
@@ -1029,7 +1029,7 @@  int vb2_ioctl_create_bufs(struct file *file, void *priv,
 	int res = vb2_verify_memory_type(vdev->queue, p->memory,
 			p->format.type);
 
-	p->index = vdev->queue->num_buffers;
+	p->index = vb2_get_num_buffers(vdev->queue);
 	fill_buf_caps(vdev->queue, &p->capabilities);
 	validate_memory_flags(vdev->queue, p->memory, &p->flags);
 	/*