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. Signed-off-by: Hans Verkuil <hverkuil-cisco@xxxxxxxxx> Cc: Dafna Hirschfeld <dafna.hirschfeld@xxxxxxxxxxxxx> Cc: Sowjanya Komatineni <skomatineni@xxxxxxxxxx> Cc: Neil Armstrong <narmstrong@xxxxxxxxxxxx> --- drivers/staging/media/meson/vdec/vdec.c | 8 +------- drivers/staging/media/rkisp1/rkisp1-capture.c | 2 +- drivers/staging/media/rkisp1/rkisp1-params.c | 7 ++----- drivers/staging/media/rkisp1/rkisp1-stats.c | 6 ++---- drivers/staging/media/tegra-video/vi.c | 8 ++------ 5 files changed, 8 insertions(+), 23 deletions(-) diff --git a/drivers/staging/media/meson/vdec/vdec.c b/drivers/staging/media/meson/vdec/vdec.c index 3040136ceb77..5ccb3846c879 100644 --- a/drivers/staging/media/meson/vdec/vdec.c +++ b/drivers/staging/media/meson/vdec/vdec.c @@ -841,13 +841,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq, dst_vq->min_buffers_needed = 1; dst_vq->dev = sess->core->dev; dst_vq->lock = &sess->lock; - 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_init_ctrls(struct amvdec_session *sess) diff --git a/drivers/staging/media/rkisp1/rkisp1-capture.c b/drivers/staging/media/rkisp1/rkisp1-capture.c index 793ec884c894..2a25c3a99ea4 100644 --- a/drivers/staging/media/rkisp1/rkisp1-capture.c +++ b/drivers/staging/media/rkisp1/rkisp1-capture.c @@ -1277,7 +1277,7 @@ static const struct v4l2_file_operations rkisp1_fops = { static void rkisp1_unregister_capture(struct rkisp1_capture *cap) { media_entity_cleanup(&cap->vnode.vdev.entity); - video_unregister_device(&cap->vnode.vdev); + vb2_video_unregister_device(&cap->vnode.vdev); } void rkisp1_capture_devs_unregister(struct rkisp1_device *rkisp1) diff --git a/drivers/staging/media/rkisp1/rkisp1-params.c b/drivers/staging/media/rkisp1/rkisp1-params.c index 797e79de659c..bea074950fc1 100644 --- a/drivers/staging/media/rkisp1/rkisp1-params.c +++ b/drivers/staging/media/rkisp1/rkisp1-params.c @@ -1604,7 +1604,7 @@ int rkisp1_params_register(struct rkisp1_params *params, node->pad.flags = MEDIA_PAD_FL_SOURCE; ret = media_entity_pads_init(&vdev->entity, 1, &node->pad); if (ret) - goto err_release_queue; + return ret; ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1); if (ret) { dev_err(rkisp1->dev, @@ -1614,8 +1614,6 @@ int rkisp1_params_register(struct rkisp1_params *params, return 0; err_cleanup_media_entity: media_entity_cleanup(&vdev->entity); -err_release_queue: - vb2_queue_release(vdev->queue); return ret; } @@ -1624,7 +1622,6 @@ void rkisp1_params_unregister(struct rkisp1_params *params) struct rkisp1_vdev_node *node = ¶ms->vnode; struct video_device *vdev = &node->vdev; - video_unregister_device(vdev); + vb2_video_unregister_device(vdev); media_entity_cleanup(&vdev->entity); - vb2_queue_release(vdev->queue); } diff --git a/drivers/staging/media/rkisp1/rkisp1-stats.c b/drivers/staging/media/rkisp1/rkisp1-stats.c index 0616793ae395..7345721a8e99 100644 --- a/drivers/staging/media/rkisp1/rkisp1-stats.c +++ b/drivers/staging/media/rkisp1/rkisp1-stats.c @@ -498,11 +498,10 @@ int rkisp1_stats_register(struct rkisp1_stats *stats, return 0; err_unreg_vdev: - video_unregister_device(vdev); + vb2_video_unregister_device(vdev); err_cleanup_media_entity: media_entity_cleanup(&vdev->entity); err_release_queue: - vb2_queue_release(vdev->queue); mutex_destroy(&node->vlock); mutex_destroy(&stats->wq_lock); return ret; @@ -514,9 +513,8 @@ void rkisp1_stats_unregister(struct rkisp1_stats *stats) struct video_device *vdev = &node->vdev; destroy_workqueue(stats->readout_wq); - video_unregister_device(vdev); + vb2_video_unregister_device(vdev); media_entity_cleanup(&vdev->entity); - vb2_queue_release(vdev->queue); mutex_destroy(&node->vlock); mutex_destroy(&stats->wq_lock); } diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 1b5e660155f5..a3b9b212f8c8 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -795,12 +795,8 @@ void tegra_v4l2_nodes_cleanup_tpg(struct tegra_video_device *vid) struct tegra_csi_channel *csi_chan; struct tegra_vi_channel *chan; - list_for_each_entry(chan, &vi->vi_chans, list) { - video_unregister_device(&chan->video); - mutex_lock(&chan->video_lock); - vb2_queue_release(&chan->queue); - mutex_unlock(&chan->video_lock); - } + list_for_each_entry(chan, &vi->vi_chans, list) + vb2_video_unregister_device(&chan->video); list_for_each_entry(csi_chan, &csi->csi_chans, list) v4l2_device_unregister_subdev(&csi_chan->subdev); -- 2.27.0