media: media/test-drivers: use vb2_video_unregister_device()
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Mon, 13 Jul 2020 11:30:47 +0000 (13:30 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Fri, 28 Aug 2020 13:05:40 +0000 (15:05 +0200)
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 <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/test-drivers/vimc/vimc-capture.c
drivers/media/test-drivers/vivid/vivid-core.c

index c63496b..5e9fd90 100644 (file)
@@ -351,8 +351,7 @@ static void vimc_cap_unregister(struct vimc_ent_device *ved)
        struct vimc_cap_device *vcap =
                container_of(ved, struct vimc_cap_device, ved);
 
-       vb2_queue_release(&vcap->queue);
-       video_unregister_device(&vcap->vdev);
+       vb2_video_unregister_device(&vcap->vdev);
 }
 
 static void *vimc_cap_process_frame(struct vimc_ent_device *ved,
@@ -477,13 +476,11 @@ static struct vimc_ent_device *vimc_cap_add(struct vimc_device *vimc,
        if (ret) {
                dev_err(vimc->mdev.dev, "%s: video register failed (err=%d)\n",
                        vcap->vdev.name, ret);
-               goto err_release_queue;
+               goto err_clean_m_ent;
        }
 
        return &vcap->ved;
 
-err_release_queue:
-       vb2_queue_release(q);
 err_clean_m_ent:
        media_entity_cleanup(&vcap->vdev.entity);
 err_free_vcap:
index f7ee37e..931218f 100644 (file)
@@ -1827,16 +1827,16 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
        return 0;
 
 unreg_dev:
-       video_unregister_device(&dev->touch_cap_dev);
-       video_unregister_device(&dev->meta_out_dev);
-       video_unregister_device(&dev->meta_cap_dev);
+       vb2_video_unregister_device(&dev->touch_cap_dev);
+       vb2_video_unregister_device(&dev->meta_out_dev);
+       vb2_video_unregister_device(&dev->meta_cap_dev);
        video_unregister_device(&dev->radio_tx_dev);
        video_unregister_device(&dev->radio_rx_dev);
-       video_unregister_device(&dev->sdr_cap_dev);
-       video_unregister_device(&dev->vbi_out_dev);
-       video_unregister_device(&dev->vbi_cap_dev);
-       video_unregister_device(&dev->vid_out_dev);
-       video_unregister_device(&dev->vid_cap_dev);
+       vb2_video_unregister_device(&dev->sdr_cap_dev);
+       vb2_video_unregister_device(&dev->vbi_out_dev);
+       vb2_video_unregister_device(&dev->vbi_cap_dev);
+       vb2_video_unregister_device(&dev->vid_out_dev);
+       vb2_video_unregister_device(&dev->vid_cap_dev);
        cec_unregister_adapter(dev->cec_rx_adap);
        for (i = 0; i < MAX_OUTPUTS; i++)
                cec_unregister_adapter(dev->cec_tx_adap[i]);
@@ -1907,27 +1907,27 @@ static int vivid_remove(struct platform_device *pdev)
                if (dev->has_vid_cap) {
                        v4l2_info(&dev->v4l2_dev, "unregistering %s\n",
                                video_device_node_name(&dev->vid_cap_dev));
-                       video_unregister_device(&dev->vid_cap_dev);
+                       vb2_video_unregister_device(&dev->vid_cap_dev);
                }
                if (dev->has_vid_out) {
                        v4l2_info(&dev->v4l2_dev, "unregistering %s\n",
                                video_device_node_name(&dev->vid_out_dev));
-                       video_unregister_device(&dev->vid_out_dev);
+                       vb2_video_unregister_device(&dev->vid_out_dev);
                }
                if (dev->has_vbi_cap) {
                        v4l2_info(&dev->v4l2_dev, "unregistering %s\n",
                                video_device_node_name(&dev->vbi_cap_dev));
-                       video_unregister_device(&dev->vbi_cap_dev);
+                       vb2_video_unregister_device(&dev->vbi_cap_dev);
                }
                if (dev->has_vbi_out) {
                        v4l2_info(&dev->v4l2_dev, "unregistering %s\n",
                                video_device_node_name(&dev->vbi_out_dev));
-                       video_unregister_device(&dev->vbi_out_dev);
+                       vb2_video_unregister_device(&dev->vbi_out_dev);
                }
                if (dev->has_sdr_cap) {
                        v4l2_info(&dev->v4l2_dev, "unregistering %s\n",
                                video_device_node_name(&dev->sdr_cap_dev));
-                       video_unregister_device(&dev->sdr_cap_dev);
+                       vb2_video_unregister_device(&dev->sdr_cap_dev);
                }
                if (dev->has_radio_rx) {
                        v4l2_info(&dev->v4l2_dev, "unregistering %s\n",
@@ -1948,17 +1948,17 @@ static int vivid_remove(struct platform_device *pdev)
                if (dev->has_meta_cap) {
                        v4l2_info(&dev->v4l2_dev, "unregistering %s\n",
                                  video_device_node_name(&dev->meta_cap_dev));
-                       video_unregister_device(&dev->meta_cap_dev);
+                       vb2_video_unregister_device(&dev->meta_cap_dev);
                }
                if (dev->has_meta_out) {
                        v4l2_info(&dev->v4l2_dev, "unregistering %s\n",
                                  video_device_node_name(&dev->meta_out_dev));
-                       video_unregister_device(&dev->meta_out_dev);
+                       vb2_video_unregister_device(&dev->meta_out_dev);
                }
                if (dev->has_touch_cap) {
                        v4l2_info(&dev->v4l2_dev, "unregistering %s\n",
                                  video_device_node_name(&dev->touch_cap_dev));
-                       video_unregister_device(&dev->touch_cap_dev);
+                       vb2_video_unregister_device(&dev->touch_cap_dev);
                }
                cec_unregister_adapter(dev->cec_rx_adap);
                for (j = 0; j < MAX_OUTPUTS; j++)