Commit 11788d9b authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

media: media/pci: 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: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 492abcd7
...@@ -575,9 +575,8 @@ static void dt3155_remove(struct pci_dev *pdev) ...@@ -575,9 +575,8 @@ static void dt3155_remove(struct pci_dev *pdev)
struct dt3155_priv *pd = container_of(v4l2_dev, struct dt3155_priv, struct dt3155_priv *pd = container_of(v4l2_dev, struct dt3155_priv,
v4l2_dev); v4l2_dev);
video_unregister_device(&pd->vdev); vb2_video_unregister_device(&pd->vdev);
free_irq(pd->pdev->irq, pd); free_irq(pd->pdev->irq, pd);
vb2_queue_release(&pd->vidq);
v4l2_device_unregister(&pd->v4l2_dev); v4l2_device_unregister(&pd->v4l2_dev);
pci_iounmap(pdev, pd->regs); pci_iounmap(pdev, pd->regs);
pci_release_region(pdev, 0); pci_release_region(pdev, 0);
......
...@@ -1633,7 +1633,7 @@ static int cio2_queue_init(struct cio2_device *cio2, struct cio2_queue *q) ...@@ -1633,7 +1633,7 @@ static int cio2_queue_init(struct cio2_device *cio2, struct cio2_queue *q)
if (r) { if (r) {
dev_err(&cio2->pci_dev->dev, dev_err(&cio2->pci_dev->dev,
"failed to initialize videobuf2 queue (%d)\n", r); "failed to initialize videobuf2 queue (%d)\n", r);
goto fail_vbq; goto fail_subdev;
} }
/* Initialize vdev */ /* Initialize vdev */
...@@ -1664,10 +1664,8 @@ static int cio2_queue_init(struct cio2_device *cio2, struct cio2_queue *q) ...@@ -1664,10 +1664,8 @@ static int cio2_queue_init(struct cio2_device *cio2, struct cio2_queue *q)
return 0; return 0;
fail_link: fail_link:
video_unregister_device(&q->vdev); vb2_video_unregister_device(&q->vdev);
fail_vdev: fail_vdev:
vb2_queue_release(vbq);
fail_vbq:
v4l2_device_unregister_subdev(subdev); v4l2_device_unregister_subdev(subdev);
fail_subdev: fail_subdev:
media_entity_cleanup(&vdev->entity); media_entity_cleanup(&vdev->entity);
...@@ -1683,9 +1681,8 @@ static int cio2_queue_init(struct cio2_device *cio2, struct cio2_queue *q) ...@@ -1683,9 +1681,8 @@ static int cio2_queue_init(struct cio2_device *cio2, struct cio2_queue *q)
static void cio2_queue_exit(struct cio2_device *cio2, struct cio2_queue *q) static void cio2_queue_exit(struct cio2_device *cio2, struct cio2_queue *q)
{ {
video_unregister_device(&q->vdev); vb2_video_unregister_device(&q->vdev);
media_entity_cleanup(&q->vdev.entity); media_entity_cleanup(&q->vdev.entity);
vb2_queue_release(&q->vbq);
v4l2_device_unregister_subdev(&q->subdev); v4l2_device_unregister_subdev(&q->subdev);
media_entity_cleanup(&q->subdev.entity); media_entity_cleanup(&q->subdev.entity);
cio2_fbpt_exit(q, &cio2->pci_dev->dev); cio2_fbpt_exit(q, &cio2->pci_dev->dev);
......
...@@ -965,21 +965,21 @@ static void saa7134_unregister_video(struct saa7134_dev *dev) ...@@ -965,21 +965,21 @@ static void saa7134_unregister_video(struct saa7134_dev *dev)
if (dev->video_dev) { if (dev->video_dev) {
if (video_is_registered(dev->video_dev)) if (video_is_registered(dev->video_dev))
video_unregister_device(dev->video_dev); vb2_video_unregister_device(dev->video_dev);
else else
video_device_release(dev->video_dev); video_device_release(dev->video_dev);
dev->video_dev = NULL; dev->video_dev = NULL;
} }
if (dev->vbi_dev) { if (dev->vbi_dev) {
if (video_is_registered(dev->vbi_dev)) if (video_is_registered(dev->vbi_dev))
video_unregister_device(dev->vbi_dev); vb2_video_unregister_device(dev->vbi_dev);
else else
video_device_release(dev->vbi_dev); video_device_release(dev->vbi_dev);
dev->vbi_dev = NULL; dev->vbi_dev = NULL;
} }
if (dev->radio_dev) { if (dev->radio_dev) {
if (video_is_registered(dev->radio_dev)) if (video_is_registered(dev->radio_dev))
video_unregister_device(dev->radio_dev); vb2_video_unregister_device(dev->radio_dev);
else else
video_device_release(dev->radio_dev); video_device_release(dev->radio_dev);
dev->radio_dev = NULL; dev->radio_dev = NULL;
......
...@@ -314,8 +314,7 @@ static int empress_fini(struct saa7134_dev *dev) ...@@ -314,8 +314,7 @@ static int empress_fini(struct saa7134_dev *dev)
if (NULL == dev->empress_dev) if (NULL == dev->empress_dev)
return 0; return 0;
flush_work(&dev->empress_workqueue); flush_work(&dev->empress_workqueue);
video_unregister_device(dev->empress_dev); vb2_video_unregister_device(dev->empress_dev);
vb2_queue_release(&dev->empress_vbq);
v4l2_ctrl_handler_free(&dev->empress_ctrl_handler); v4l2_ctrl_handler_free(&dev->empress_ctrl_handler);
dev->empress_dev = NULL; dev->empress_dev = NULL;
return 0; return 0;
......
...@@ -493,7 +493,7 @@ static int saa7134_go7007_fini(struct saa7134_dev *dev) ...@@ -493,7 +493,7 @@ static int saa7134_go7007_fini(struct saa7134_dev *dev)
free_page((unsigned long)saa->bottom); free_page((unsigned long)saa->bottom);
v4l2_device_unregister_subdev(&saa->sd); v4l2_device_unregister_subdev(&saa->sd);
kfree(saa); kfree(saa);
video_unregister_device(&go->vdev); vb2_video_unregister_device(&go->vdev);
v4l2_device_put(&go->v4l2_dev); v4l2_device_put(&go->v4l2_dev);
dev->empress_dev = NULL; dev->empress_dev = NULL;
......
...@@ -2154,9 +2154,7 @@ int saa7134_video_init1(struct saa7134_dev *dev) ...@@ -2154,9 +2154,7 @@ int saa7134_video_init1(struct saa7134_dev *dev)
void saa7134_video_fini(struct saa7134_dev *dev) void saa7134_video_fini(struct saa7134_dev *dev)
{ {
/* free stuff */ /* free stuff */
vb2_queue_release(&dev->video_vbq);
saa7134_pgtable_free(dev->pci, &dev->video_q.pt); saa7134_pgtable_free(dev->pci, &dev->video_q.pt);
vb2_queue_release(&dev->vbi_vbq);
saa7134_pgtable_free(dev->pci, &dev->vbi_q.pt); saa7134_pgtable_free(dev->pci, &dev->vbi_q.pt);
v4l2_ctrl_handler_free(&dev->ctrl_handler); v4l2_ctrl_handler_free(&dev->ctrl_handler);
if (card_has_radio(dev)) if (card_has_radio(dev))
......
...@@ -1101,12 +1101,11 @@ static int sta2x11_vip_init_one(struct pci_dev *pdev, ...@@ -1101,12 +1101,11 @@ static int sta2x11_vip_init_one(struct pci_dev *pdev,
vunreg: vunreg:
video_set_drvdata(&vip->video_dev, NULL); video_set_drvdata(&vip->video_dev, NULL);
vrelease: vrelease:
video_unregister_device(&vip->video_dev); vb2_video_unregister_device(&vip->video_dev);
free_irq(pdev->irq, vip); free_irq(pdev->irq, vip);
release_buf: release_buf:
pci_disable_msi(pdev); pci_disable_msi(pdev);
unmap: unmap:
vb2_queue_release(&vip->vb_vidq);
pci_iounmap(pdev, vip->iomem); pci_iounmap(pdev, vip->iomem);
release: release:
pci_release_regions(pdev); pci_release_regions(pdev);
...@@ -1146,10 +1145,9 @@ static void sta2x11_vip_remove_one(struct pci_dev *pdev) ...@@ -1146,10 +1145,9 @@ static void sta2x11_vip_remove_one(struct pci_dev *pdev)
sta2x11_vip_clear_register(vip); sta2x11_vip_clear_register(vip);
video_set_drvdata(&vip->video_dev, NULL); video_set_drvdata(&vip->video_dev, NULL);
video_unregister_device(&vip->video_dev); vb2_video_unregister_device(&vip->video_dev);
free_irq(pdev->irq, vip); free_irq(pdev->irq, vip);
pci_disable_msi(pdev); pci_disable_msi(pdev);
vb2_queue_release(&vip->vb_vidq);
pci_iounmap(pdev, vip->iomem); pci_iounmap(pdev, vip->iomem);
pci_release_regions(pdev); pci_release_regions(pdev);
......
...@@ -1178,7 +1178,6 @@ static int tw5864_video_input_init(struct tw5864_input *input, int video_nr) ...@@ -1178,7 +1178,6 @@ static int tw5864_video_input_init(struct tw5864_input *input, int video_nr)
free_v4l2_hdl: free_v4l2_hdl:
v4l2_ctrl_handler_free(hdl); v4l2_ctrl_handler_free(hdl);
vb2_queue_release(&input->vidq);
free_mutex: free_mutex:
mutex_destroy(&input->lock); mutex_destroy(&input->lock);
...@@ -1187,9 +1186,8 @@ static int tw5864_video_input_init(struct tw5864_input *input, int video_nr) ...@@ -1187,9 +1186,8 @@ static int tw5864_video_input_init(struct tw5864_input *input, int video_nr)
static void tw5864_video_input_fini(struct tw5864_input *dev) static void tw5864_video_input_fini(struct tw5864_input *dev)
{ {
video_unregister_device(&dev->vdev); vb2_video_unregister_device(&dev->vdev);
v4l2_ctrl_handler_free(&dev->hdl); v4l2_ctrl_handler_free(&dev->hdl);
vb2_queue_release(&dev->vidq);
} }
void tw5864_video_fini(struct tw5864_dev *dev) void tw5864_video_fini(struct tw5864_dev *dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment