diff mbox series

[7/9] media: video-i2c: set lock before calling vb2_queue_init()

Message ID 42695db9edcf5e6b5ddebab59338eb88a5abcebe.1725285495.git.hverkuil-cisco@xs4all.nl (mailing list archive)
State New
Headers show
Series media: vb2: prepare for vb2_ops_wait_prepare/finish removal | expand

Commit Message

Hans Verkuil Sept. 2, 2024, 2:04 p.m. UTC
The vb2_queue_init() will expect the vb2_queue lock pointer to be set in
the future. So for those drivers that set the lock later, move it up to
before the vb2_queue_init() call.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Matt Ranostay <matt@ranostay.sg>
---
 drivers/media/i2c/video-i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Matt Ranostay Sept. 2, 2024, 2:32 p.m. UTC | #1
Sent with Proton Mail secure email.

On Monday, September 2nd, 2024 at 22:04, Hans Verkuil <hverkuil-cisco@xs4all.nl> wrote:

> The vb2_queue_init() will expect the vb2_queue lock pointer to be set in
> the future. So for those drivers that set the lock later, move it up to
> before the vb2_queue_init() call.
> 
> Signed-off-by: Hans Verkuil hverkuil-cisco@xs4all.nl
> 

LGTM

Acked-by: Matt Ranostay <matt@ranostay.sg>

> Cc: Matt Ranostay matt@ranostay.sg
> 
> ---
> drivers/media/i2c/video-i2c.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c
> index 56dbe07a1c99..ffb3d9d61a74 100644
> --- a/drivers/media/i2c/video-i2c.c
> +++ b/drivers/media/i2c/video-i2c.c
> @@ -798,13 +798,13 @@ static int video_i2c_probe(struct i2c_client *client)
> queue->min_queued_buffers = 1;
> 
> queue->ops = &video_i2c_video_qops;
> 
> queue->mem_ops = &vb2_vmalloc_memops;
> 
> + queue->lock = &data->queue_lock;
> 
> 
> ret = vb2_queue_init(queue);
> if (ret < 0)
> goto error_unregister_device;
> 
> data->vdev.queue = queue;
> 
> - data->vdev.queue->lock = &data->queue_lock;
> 
> 
> snprintf(data->vdev.name, sizeof(data->vdev.name),
> 
> "I2C %d-%d Transport Video",
> --
> 2.34.1
Laurent Pinchart Sept. 9, 2024, 2:52 p.m. UTC | #2
Hi Hans,

Thank you for the patch.

On Mon, Sep 02, 2024 at 04:04:53PM +0200, Hans Verkuil wrote:
> The vb2_queue_init() will expect the vb2_queue lock pointer to be set in
> the future. So for those drivers that set the lock later, move it up to
> before the vb2_queue_init() call.
> 
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> Cc: Matt Ranostay <matt@ranostay.sg>

Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

> ---
>  drivers/media/i2c/video-i2c.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c
> index 56dbe07a1c99..ffb3d9d61a74 100644
> --- a/drivers/media/i2c/video-i2c.c
> +++ b/drivers/media/i2c/video-i2c.c
> @@ -798,13 +798,13 @@ static int video_i2c_probe(struct i2c_client *client)
>  	queue->min_queued_buffers = 1;
>  	queue->ops = &video_i2c_video_qops;
>  	queue->mem_ops = &vb2_vmalloc_memops;
> +	queue->lock = &data->queue_lock;
>  
>  	ret = vb2_queue_init(queue);
>  	if (ret < 0)
>  		goto error_unregister_device;
>  
>  	data->vdev.queue = queue;
> -	data->vdev.queue->lock = &data->queue_lock;
>  
>  	snprintf(data->vdev.name, sizeof(data->vdev.name),
>  				 "I2C %d-%d Transport Video",
diff mbox series

Patch

diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c
index 56dbe07a1c99..ffb3d9d61a74 100644
--- a/drivers/media/i2c/video-i2c.c
+++ b/drivers/media/i2c/video-i2c.c
@@ -798,13 +798,13 @@  static int video_i2c_probe(struct i2c_client *client)
 	queue->min_queued_buffers = 1;
 	queue->ops = &video_i2c_video_qops;
 	queue->mem_ops = &vb2_vmalloc_memops;
+	queue->lock = &data->queue_lock;
 
 	ret = vb2_queue_init(queue);
 	if (ret < 0)
 		goto error_unregister_device;
 
 	data->vdev.queue = queue;
-	data->vdev.queue->lock = &data->queue_lock;
 
 	snprintf(data->vdev.name, sizeof(data->vdev.name),
 				 "I2C %d-%d Transport Video",