[2/9] media: pwc: set lock before calling vb2_queue_init()

Message ID 91ca5c3db14df7b8d8dc4189aa73ed38ca97975e.1725285495.git.hverkuil-cisco@xs4all.nl (mailing list archive)
State New
Delegated to: Hans Verkuil
Headers
Series media: vb2: prepare for vb2_ops_wait_prepare/finish removal |

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>
---
 drivers/media/usb/pwc/pwc-if.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Laurent Pinchart Sept. 9, 2024, 2:53 p.m. UTC | #1
Hi Hans,

Thank you for the patch.

On Mon, Sep 02, 2024 at 04:04:48PM +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>

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

> ---
>  drivers/media/usb/pwc/pwc-if.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c
> index e342199711d3..4a8485ea0c81 100644
> --- a/drivers/media/usb/pwc/pwc-if.c
> +++ b/drivers/media/usb/pwc/pwc-if.c
> @@ -1054,6 +1054,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
>  	pdev->vb_queue.ops = &pwc_vb_queue_ops;
>  	pdev->vb_queue.mem_ops = &vb2_vmalloc_memops;
>  	pdev->vb_queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> +	pdev->vb_queue.lock = &pdev->vb_queue_lock;
>  	rc = vb2_queue_init(&pdev->vb_queue);
>  	if (rc < 0) {
>  		PWC_ERROR("Oops, could not initialize vb2 queue.\n");
> @@ -1064,7 +1065,6 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
>  	pdev->vdev = pwc_template;
>  	strscpy(pdev->vdev.name, name, sizeof(pdev->vdev.name));
>  	pdev->vdev.queue = &pdev->vb_queue;
> -	pdev->vdev.queue->lock = &pdev->vb_queue_lock;
>  	video_set_drvdata(&pdev->vdev, pdev);
>  
>  	pdev->release = le16_to_cpu(udev->descriptor.bcdDevice);
  

Patch

diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c
index e342199711d3..4a8485ea0c81 100644
--- a/drivers/media/usb/pwc/pwc-if.c
+++ b/drivers/media/usb/pwc/pwc-if.c
@@ -1054,6 +1054,7 @@  static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
 	pdev->vb_queue.ops = &pwc_vb_queue_ops;
 	pdev->vb_queue.mem_ops = &vb2_vmalloc_memops;
 	pdev->vb_queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+	pdev->vb_queue.lock = &pdev->vb_queue_lock;
 	rc = vb2_queue_init(&pdev->vb_queue);
 	if (rc < 0) {
 		PWC_ERROR("Oops, could not initialize vb2 queue.\n");
@@ -1064,7 +1065,6 @@  static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
 	pdev->vdev = pwc_template;
 	strscpy(pdev->vdev.name, name, sizeof(pdev->vdev.name));
 	pdev->vdev.queue = &pdev->vb_queue;
-	pdev->vdev.queue->lock = &pdev->vb_queue_lock;
 	video_set_drvdata(&pdev->vdev, pdev);
 
 	pdev->release = le16_to_cpu(udev->descriptor.bcdDevice);