diff mbox series

[v14,25/56] media: pci: tw68: Stop direct calls to queue num_buffers field

Message ID 20231031163104.112469-26-benjamin.gaignard@collabora.com (mailing list archive)
State New, archived
Headers show
Series Add DELETE_BUF ioctl | expand

Commit Message

Benjamin Gaignard Oct. 31, 2023, 4:30 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>
CC: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
---
 drivers/media/pci/tw68/tw68-video.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Andrzej Pietrasiewicz Nov. 9, 2023, 10:13 a.m. UTC | #1
Hi Benjamin,

W dniu 31.10.2023 o 17:30, Benjamin Gaignard pisze:
> 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>
> CC: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
> ---
>   drivers/media/pci/tw68/tw68-video.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c
> index 773a18702d36..35296c226019 100644
> --- a/drivers/media/pci/tw68/tw68-video.c
> +++ b/drivers/media/pci/tw68/tw68-video.c
> @@ -360,13 +360,13 @@ static int tw68_queue_setup(struct vb2_queue *q,
>   			   unsigned int sizes[], struct device *alloc_devs[])
>   {
>   	struct tw68_dev *dev = vb2_get_drv_priv(q);

Why not

	unsigned int q_num_bufs = vb2_get_num_buffers(vq);

just like in other patches in the series?

Regards,

Andrzej

> -	unsigned tot_bufs = q->num_buffers + *num_buffers;
> +	unsigned tot_bufs = vb2_get_num_buffers(q) + *num_buffers;
>   	unsigned size = (dev->fmt->depth * dev->width * dev->height) >> 3;
>   
>   	if (tot_bufs < 2)
>   		tot_bufs = 2;
>   	tot_bufs = tw68_buffer_count(size, tot_bufs);
> -	*num_buffers = tot_bufs - q->num_buffers;
> +	*num_buffers = tot_bufs - vb2_get_num_buffers(q);
>   	/*
>   	 * We allow create_bufs, but only if the sizeimage is >= as the
>   	 * current sizeimage. The tw68_buffer_count calculation becomes quite
Benjamin Gaignard Nov. 9, 2023, 10:23 a.m. UTC | #2
Le 09/11/2023 à 11:13, Andrzej Pietrasiewicz a écrit :
> Hi Benjamin,
>
> W dniu 31.10.2023 o 17:30, Benjamin Gaignard pisze:
>> 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>
>> CC: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
>> ---
>>   drivers/media/pci/tw68/tw68-video.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/media/pci/tw68/tw68-video.c 
>> b/drivers/media/pci/tw68/tw68-video.c
>> index 773a18702d36..35296c226019 100644
>> --- a/drivers/media/pci/tw68/tw68-video.c
>> +++ b/drivers/media/pci/tw68/tw68-video.c
>> @@ -360,13 +360,13 @@ static int tw68_queue_setup(struct vb2_queue *q,
>>                  unsigned int sizes[], struct device *alloc_devs[])
>>   {
>>       struct tw68_dev *dev = vb2_get_drv_priv(q);
>
> Why not
>
>     unsigned int q_num_bufs = vb2_get_num_buffers(vq);
>
> just like in other patches in the series?

You are right, I will change it to keep the same pattern than for the other patches.

Regards,
Benjamin

>
> Regards,
>
> Andrzej
>
>> -    unsigned tot_bufs = q->num_buffers + *num_buffers;
>> +    unsigned tot_bufs = vb2_get_num_buffers(q) + *num_buffers;
>>       unsigned size = (dev->fmt->depth * dev->width * dev->height) >> 3;
>>         if (tot_bufs < 2)
>>           tot_bufs = 2;
>>       tot_bufs = tw68_buffer_count(size, tot_bufs);
>> -    *num_buffers = tot_bufs - q->num_buffers;
>> +    *num_buffers = tot_bufs - vb2_get_num_buffers(q);
>>       /*
>>        * We allow create_bufs, but only if the sizeimage is >= as the
>>        * current sizeimage. The tw68_buffer_count calculation becomes 
>> quite
>
>
diff mbox series

Patch

diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c
index 773a18702d36..35296c226019 100644
--- a/drivers/media/pci/tw68/tw68-video.c
+++ b/drivers/media/pci/tw68/tw68-video.c
@@ -360,13 +360,13 @@  static int tw68_queue_setup(struct vb2_queue *q,
 			   unsigned int sizes[], struct device *alloc_devs[])
 {
 	struct tw68_dev *dev = vb2_get_drv_priv(q);
-	unsigned tot_bufs = q->num_buffers + *num_buffers;
+	unsigned tot_bufs = vb2_get_num_buffers(q) + *num_buffers;
 	unsigned size = (dev->fmt->depth * dev->width * dev->height) >> 3;
 
 	if (tot_bufs < 2)
 		tot_bufs = 2;
 	tot_bufs = tw68_buffer_count(size, tot_bufs);
-	*num_buffers = tot_bufs - q->num_buffers;
+	*num_buffers = tot_bufs - vb2_get_num_buffers(q);
 	/*
 	 * We allow create_bufs, but only if the sizeimage is >= as the
 	 * current sizeimage. The tw68_buffer_count calculation becomes quite