diff mbox series

[6/7] usb: gadget: uvc: ensure the vdev is unset

Message ID 20210930102717.15720-7-m.grzeschik@pengutronix.de (mailing list archive)
State Superseded
Headers show
Series usb: gadget: uvc: smaller fixes for stability | expand

Commit Message

Michael Grzeschik Sept. 30, 2021, 10:27 a.m. UTC
Since the uvc video device will be created on demand, we have to ensure
that the struct is always unprepared. Otherwise the previous settings
will colide with the new perparation.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
 drivers/usb/gadget/function/f_uvc.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Paul Elder Oct. 1, 2021, 3:07 a.m. UTC | #1
On Thu, Sep 30, 2021 at 12:27:16PM +0200, Michael Grzeschik wrote:
> Since the uvc video device will be created on demand, we have to ensure

s/will be/is/

> that the struct is always unprepared. Otherwise the previous settings

s/unprepared/zeroed/

> will colide with the new perparation.

s/will/might/

s/colide/collide/

s/perparation/values/ ? Or s/perparation/preparation/

> 
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  drivers/usb/gadget/function/f_uvc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
> index 1e93ab5c0c88d..b3279ba357331 100644
> --- a/drivers/usb/gadget/function/f_uvc.c
> +++ b/drivers/usb/gadget/function/f_uvc.c
> @@ -417,6 +417,7 @@ uvc_register_video(struct uvc_device *uvc)
>  	int ret;
>  
>  	/* TODO reference counting. */
> +	memset(&uvc->vdev, 0, sizeof(struct video_device));
>  	uvc->vdev.v4l2_dev = &uvc->v4l2_dev;
>  	uvc->vdev.v4l2_dev->dev = &cdev->gadget->dev;
>  	uvc->vdev.fops = &uvc_v4l2_fops;
> -- 
> 2.30.2
>
Laurent Pinchart Oct. 4, 2021, 10:31 p.m. UTC | #2
Hi Michael,

Thank you for the patch.

On Thu, Sep 30, 2021 at 12:27:16PM +0200, Michael Grzeschik wrote:
> Since the uvc video device will be created on demand, we have to ensure
> that the struct is always unprepared. Otherwise the previous settings
> will colide with the new perparation.
> 
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> ---
>  drivers/usb/gadget/function/f_uvc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
> index 1e93ab5c0c88d..b3279ba357331 100644
> --- a/drivers/usb/gadget/function/f_uvc.c
> +++ b/drivers/usb/gadget/function/f_uvc.c
> @@ -417,6 +417,7 @@ uvc_register_video(struct uvc_device *uvc)
>  	int ret;
>  
>  	/* TODO reference counting. */
> +	memset(&uvc->vdev, 0, sizeof(struct video_device));

	memset(&uvc->vdev, 0, sizeof(uvc->video));

With this and the commit message changes pointed out by Paul,

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

>  	uvc->vdev.v4l2_dev = &uvc->v4l2_dev;
>  	uvc->vdev.v4l2_dev->dev = &cdev->gadget->dev;
>  	uvc->vdev.fops = &uvc_v4l2_fops;
diff mbox series

Patch

diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
index 1e93ab5c0c88d..b3279ba357331 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -417,6 +417,7 @@  uvc_register_video(struct uvc_device *uvc)
 	int ret;
 
 	/* TODO reference counting. */
+	memset(&uvc->vdev, 0, sizeof(struct video_device));
 	uvc->vdev.v4l2_dev = &uvc->v4l2_dev;
 	uvc->vdev.v4l2_dev->dev = &cdev->gadget->dev;
 	uvc->vdev.fops = &uvc_v4l2_fops;