Skip to content

Commit

Permalink
media: media videobuf2: Stop direct calls to queue num_buffers field
Browse files Browse the repository at this point in the history
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.

Fixes: d055a76 ("media: core: Report the maximum possible number of buffers for the queue")
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Acked-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
  • Loading branch information
Benjamin Gaignard authored and Hans Verkuil committed Jan 24, 2024
1 parent c14d17a commit 78e23c3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/media/common/videobuf2/videobuf2-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/common/videobuf2/videobuf2-v4l2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
/*
Expand Down

0 comments on commit 78e23c3

Please sign in to comment.