Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: usb: hackrf: 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.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
CC: Antti Palosaari <crope@iki.fi>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

authored by

Benjamin Gaignard and committed by
Mauro Carvalho Chehab
7e17d44d ca44d57a

+3 -2
+3 -2
drivers/media/usb/hackrf/hackrf.c
··· 753 753 unsigned int *nplanes, unsigned int sizes[], struct device *alloc_devs[]) 754 754 { 755 755 struct hackrf_dev *dev = vb2_get_drv_priv(vq); 756 + unsigned int q_num_bufs = vb2_get_num_buffers(vq); 756 757 757 758 dev_dbg(dev->dev, "nbuffers=%d\n", *nbuffers); 758 759 759 760 /* Need at least 8 buffers */ 760 - if (vq->num_buffers + *nbuffers < 8) 761 - *nbuffers = 8 - vq->num_buffers; 761 + if (q_num_bufs + *nbuffers < 8) 762 + *nbuffers = 8 - q_num_bufs; 762 763 *nplanes = 1; 763 764 sizes[0] = PAGE_ALIGN(dev->buffersize); 764 765