From: Hans Verkuil Date: Mon, 13 Jul 2020 11:30:46 +0000 (+0200) Subject: media: media/usb: use vb2_video_unregister_device() X-Git-Tag: v5.15~2723^2~525 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=24b5836dbd45b9b4bef6c3b87d512dade8e1f6e1;p=platform%2Fkernel%2Flinux-starfive.git media: media/usb: use vb2_video_unregister_device() Use vb2_video_unregister_device() to automatically stop streaming at unregister time. This avoids the use of vb2_queue_release() which should not be called by drivers that set vdev->queue. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index 51b8d14..aa5bc6a 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c @@ -938,8 +938,8 @@ int au0828_analog_unregister(struct au0828_dev *dev) return 0; mutex_lock(&au0828_sysfs_lock); - video_unregister_device(&dev->vdev); - video_unregister_device(&dev->vbi_dev); + vb2_video_unregister_device(&dev->vdev); + vb2_video_unregister_device(&dev->vbi_dev); mutex_unlock(&au0828_sysfs_lock); v4l2_device_disconnect(&dev->v4l2_dev); @@ -2011,8 +2011,7 @@ int au0828_analog_register(struct au0828_dev *dev, if (retval != 0) { dprintk(1, "unable to register video device (error = %d).\n", retval); - ret = -ENODEV; - goto err_reg_vdev; + return -ENODEV; } /* Register the vbi device */ @@ -2040,10 +2039,7 @@ int au0828_analog_register(struct au0828_dev *dev, return 0; err_reg_vbi_dev: - video_unregister_device(&dev->vdev); -err_reg_vdev: - vb2_queue_release(&dev->vb_vidq); - vb2_queue_release(&dev->vb_vbiq); + vb2_video_unregister_device(&dev->vdev); return ret; } diff --git a/drivers/media/usb/dvb-usb/cxusb-analog.c b/drivers/media/usb/dvb-usb/cxusb-analog.c index 001cae6..e93183d 100644 --- a/drivers/media/usb/dvb-usb/cxusb-analog.c +++ b/drivers/media/usb/dvb-usb/cxusb-analog.c @@ -1615,8 +1615,6 @@ static void cxusb_medion_videodev_release(struct video_device *vdev) cxusb_vprintk(dvbdev, OPS, "video device release\n"); - vb2_queue_release(vdev->queue); - video_device_release(vdev); } @@ -1647,8 +1645,7 @@ static int cxusb_medion_register_analog_video(struct dvb_usb_device *dvbdev) cxdev->videodev = video_device_alloc(); if (!cxdev->videodev) { dev_err(&dvbdev->udev->dev, "video device alloc failed\n"); - ret = -ENOMEM; - goto ret_qrelease; + return -ENOMEM; } cxdev->videodev->device_caps = videocaps; @@ -1674,10 +1671,6 @@ static int cxusb_medion_register_analog_video(struct dvb_usb_device *dvbdev) ret_vrelease: video_device_release(cxdev->videodev); - -ret_qrelease: - vb2_queue_release(&cxdev->videoqueue); - return ret; } @@ -1820,7 +1813,7 @@ int cxusb_medion_register_analog(struct dvb_usb_device *dvbdev) return 0; ret_vunreg: - video_unregister_device(cxdev->videodev); + vb2_video_unregister_device(cxdev->videodev); ret_unregister: v4l2_device_put(&cxdev->v4l2dev); @@ -1836,7 +1829,7 @@ void cxusb_medion_unregister_analog(struct dvb_usb_device *dvbdev) cxusb_vprintk(dvbdev, OPS, "unregistering analog\n"); video_unregister_device(cxdev->radiodev); - video_unregister_device(cxdev->videodev); + vb2_video_unregister_device(cxdev->videodev); v4l2_device_put(&cxdev->v4l2dev); wait_for_completion(&cxdev->v4l2_release); diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c index c89efcd..3b4a2e7 100644 --- a/drivers/media/usb/usbtv/usbtv-video.c +++ b/drivers/media/usb/usbtv/usbtv-video.c @@ -872,7 +872,6 @@ static void usbtv_release(struct v4l2_device *v4l2_dev) v4l2_device_unregister(&usbtv->v4l2_dev); v4l2_ctrl_handler_free(&usbtv->ctrl); - vb2_queue_release(&usbtv->vb2q); kfree(usbtv); } @@ -954,7 +953,6 @@ vdev_fail: v4l2_fail: ctrl_fail: v4l2_ctrl_handler_free(&usbtv->ctrl); - vb2_queue_release(&usbtv->vb2q); return ret; } @@ -965,7 +963,7 @@ void usbtv_video_free(struct usbtv *usbtv) mutex_lock(&usbtv->v4l2_lock); usbtv_stop(usbtv); - video_unregister_device(&usbtv->vdev); + vb2_video_unregister_device(&usbtv->vdev); v4l2_device_disconnect(&usbtv->v4l2_dev); mutex_unlock(&usbtv->v4l2_lock);