diff options
author | Benjamin Gaignard <benjamin.gaignard@collabora.com> | 2023-11-09 17:34:42 +0100 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@kernel.org> | 2023-11-23 12:16:25 +0100 |
commit | da53f4e6fa861bc8d454db3551f807b4a86bbb02 (patch) | |
tree | b9ce66f6a1d6b41c1d5d37ad241910d0793f62b2 /drivers/media/i2c/video-i2c.c | |
parent | media: pci: tw68: Stop direct calls to queue num_buffers field (diff) | |
download | linux-da53f4e6fa861bc8d454db3551f807b4a86bbb02.tar.xz linux-da53f4e6fa861bc8d454db3551f807b4a86bbb02.zip |
media: i2c: video-i2c: Stop direct calls to queue num_buffers field
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.
Fix the number of buffers computation at the same time.
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
CC: Matt Ranostay <matt.ranostay@konsulko.com>
Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/media/i2c/video-i2c.c')
-rw-r--r-- | drivers/media/i2c/video-i2c.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c index 178bd06cc2ed..ebf2ac98a068 100644 --- a/drivers/media/i2c/video-i2c.c +++ b/drivers/media/i2c/video-i2c.c @@ -405,9 +405,10 @@ static int queue_setup(struct vb2_queue *vq, { struct video_i2c_data *data = vb2_get_drv_priv(vq); unsigned int size = data->chip->buffer_size; + unsigned int q_num_bufs = vb2_get_num_buffers(vq); - if (vq->num_buffers + *nbuffers < 2) - *nbuffers = 2; + if (q_num_bufs + *nbuffers < 2) + *nbuffers = 2 - q_num_bufs; if (*nplanes) return sizes[0] < size ? -EINVAL : 0; |