media: media/platform: drop vb2_queue_release()
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Mon, 13 Jul 2020 11:30:45 +0000 (13:30 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Fri, 28 Aug 2020 13:02:26 +0000 (15:02 +0200)
This is only needed for drivers that do not use vb2_fop_release().
Note that vb2_queue_release() is *not* the counterpart of vb2_queue_init()
as some drivers here seem to think.

Also use vb2_video_unregister_device() to automatically stop streaming
at unregister time for those drivers that set vdev->queue.

Note that sun4i-csi didn't unregister the video device at all. That's
now fixed.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/platform/aspeed-video.c
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
drivers/media/platform/qcom/venus/vdec.c
drivers/media/platform/qcom/venus/venc.c
drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c
drivers/media/platform/sunxi/sun4i-csi/sun4i_dma.c
drivers/media/platform/sunxi/sun6i-csi/sun6i_video.c

index 7d98db1d9b524e2335297ad62f539a962b405f6b..c46a79eace98b9582c82f3b153a81b39639435c9 100644 (file)
@@ -1597,7 +1597,6 @@ static int aspeed_video_setup_video(struct aspeed_video *video)
        video_set_drvdata(vdev, video);
        rc = video_register_device(vdev, VFL_TYPE_VIDEO, 0);
        if (rc) {
-               vb2_queue_release(vbq);
                v4l2_ctrl_handler_free(&video->ctrl_handler);
                v4l2_device_unregister(v4l2_dev);
 
@@ -1737,9 +1736,7 @@ static int aspeed_video_remove(struct platform_device *pdev)
        clk_unprepare(video->vclk);
        clk_unprepare(video->eclk);
 
-       video_unregister_device(&video->vdev);
-
-       vb2_queue_release(&video->queue);
+       vb2_video_unregister_device(&video->vdev);
 
        v4l2_ctrl_handler_free(&video->ctrl_handler);
 
index 0f3e710aed4ed6cbcfe59957bdca22d3a935cd22..25b2ac03243d1d0bd6b09f276106ae2556bc41de 100644 (file)
@@ -1525,10 +1525,8 @@ int mtk_vcodec_dec_queue_init(void *priv, struct vb2_queue *src_vq,
        dst_vq->dev             = &ctx->dev->plat_dev->dev;
 
        ret = vb2_queue_init(dst_vq);
-       if (ret) {
-               vb2_queue_release(src_vq);
+       if (ret)
                mtk_v4l2_err("Failed to initialize videobuf2 queue(capture)");
-       }
 
        return ret;
 }
index 7c4c483d543894af4d8fc6f9af676f02f312a518..fbefc1634820d505fe69a39393fbc736445eed41 100644 (file)
@@ -1453,13 +1453,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
        dst_vq->allow_zero_bytesused = 1;
        dst_vq->min_buffers_needed = 0;
        dst_vq->dev = inst->core->dev;
-       ret = vb2_queue_init(dst_vq);
-       if (ret) {
-               vb2_queue_release(src_vq);
-               return ret;
-       }
-
-       return 0;
+       return vb2_queue_init(dst_vq);
 }
 
 static int vdec_open(struct file *file)
index 513bbc07f7bcca4646a83399c3db1a25b9baaaea..a4a92c2a3a281516c08394043d471ccc00bfb689 100644 (file)
@@ -1129,13 +1129,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
        dst_vq->allow_zero_bytesused = 1;
        dst_vq->min_buffers_needed = 1;
        dst_vq->dev = inst->core->dev;
-       ret = vb2_queue_init(dst_vq);
-       if (ret) {
-               vb2_queue_release(src_vq);
-               return ret;
-       }
-
-       return 0;
+       return vb2_queue_init(dst_vq);
 }
 
 static void venc_inst_init(struct venus_inst *inst)
index 5319eb1ab309274114973b19af6b745b97561e93..d226ecadff8e52a4a107fe25d237e413e6abbff0 100644 (file)
@@ -287,6 +287,7 @@ static int sun4i_csi_remove(struct platform_device *pdev)
 
        v4l2_async_notifier_unregister(&csi->notifier);
        v4l2_async_notifier_cleanup(&csi->notifier);
+       vb2_video_unregister_device(&csi->vdev);
        media_device_unregister(&csi->mdev);
        sun4i_csi_dma_unregister(csi);
        media_device_cleanup(&csi->mdev);
index 3278746246aa488768c8828b2e7b7acb91287913..2c39cd7f28622b231d25819e5cc42b71cbb2c198 100644 (file)
@@ -431,7 +431,7 @@ int sun4i_csi_dma_register(struct sun4i_csi *csi, int irq)
        ret = v4l2_device_register(csi->dev, &csi->v4l);
        if (ret) {
                dev_err(csi->dev, "Couldn't register the v4l2 device\n");
-               goto err_free_queue;
+               goto err_free_mutex;
        }
 
        ret = devm_request_irq(csi->dev, irq, sun4i_csi_irq, 0,
@@ -446,9 +446,6 @@ int sun4i_csi_dma_register(struct sun4i_csi *csi, int irq)
 err_unregister_device:
        v4l2_device_unregister(&csi->v4l);
 
-err_free_queue:
-       vb2_queue_release(q);
-
 err_free_mutex:
        mutex_destroy(&csi->lock);
        return ret;
@@ -457,6 +454,5 @@ err_free_mutex:
 void sun4i_csi_dma_unregister(struct sun4i_csi *csi)
 {
        v4l2_device_unregister(&csi->v4l);
-       vb2_queue_release(&csi->queue);
        mutex_destroy(&csi->lock);
 }
index d9648b2810b9b09c5f0df019f5b2f397ccbfb06e..b55de9ab64d8b3f3c83452d1db2a8b33d939c0b4 100644 (file)
@@ -660,13 +660,11 @@ int sun6i_video_init(struct sun6i_video *video, struct sun6i_csi *csi,
        if (ret < 0) {
                v4l2_err(&csi->v4l2_dev,
                         "video_register_device failed: %d\n", ret);
-               goto release_vb2;
+               goto clean_entity;
        }
 
        return 0;
 
-release_vb2:
-       vb2_queue_release(&video->vb2_vidq);
 clean_entity:
        media_entity_cleanup(&video->vdev.entity);
        mutex_destroy(&video->lock);
@@ -675,8 +673,7 @@ clean_entity:
 
 void sun6i_video_cleanup(struct sun6i_video *video)
 {
-       video_unregister_device(&video->vdev);
+       vb2_video_unregister_device(&video->vdev);
        media_entity_cleanup(&video->vdev.entity);
-       vb2_queue_release(&video->vb2_vidq);
        mutex_destroy(&video->lock);
 }