Commit 4db4ca74 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] sta2x11: embed video_device

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Cc: Federico Vaga <federico.vaga@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent d079f99f
...@@ -127,7 +127,7 @@ static inline struct vip_buffer *to_vip_buffer(struct vb2_buffer *vb2) ...@@ -127,7 +127,7 @@ static inline struct vip_buffer *to_vip_buffer(struct vb2_buffer *vb2)
*/ */
struct sta2x11_vip { struct sta2x11_vip {
struct v4l2_device v4l2_dev; struct v4l2_device v4l2_dev;
struct video_device *video_dev; struct video_device video_dev;
struct pci_dev *pdev; struct pci_dev *pdev;
struct i2c_adapter *adapter; struct i2c_adapter *adapter;
unsigned int register_save_area[IRQ_COUNT + SAVE_COUNT + AUX_COUNT]; unsigned int register_save_area[IRQ_COUNT + SAVE_COUNT + AUX_COUNT];
...@@ -763,7 +763,7 @@ static const struct v4l2_ioctl_ops vip_ioctl_ops = { ...@@ -763,7 +763,7 @@ static const struct v4l2_ioctl_ops vip_ioctl_ops = {
static struct video_device video_dev_template = { static struct video_device video_dev_template = {
.name = KBUILD_MODNAME, .name = KBUILD_MODNAME,
.release = video_device_release, .release = video_device_release_empty,
.fops = &vip_fops, .fops = &vip_fops,
.ioctl_ops = &vip_ioctl_ops, .ioctl_ops = &vip_ioctl_ops,
.tvnorms = V4L2_STD_ALL, .tvnorms = V4L2_STD_ALL,
...@@ -1082,19 +1082,13 @@ static int sta2x11_vip_init_one(struct pci_dev *pdev, ...@@ -1082,19 +1082,13 @@ static int sta2x11_vip_init_one(struct pci_dev *pdev,
goto release_buf; goto release_buf;
} }
/* Alloc, initialize and register video device */ /* Initialize and register video device */
vip->video_dev = video_device_alloc(); vip->video_dev = video_dev_template;
if (!vip->video_dev) { vip->video_dev.v4l2_dev = &vip->v4l2_dev;
ret = -ENOMEM; vip->video_dev.queue = &vip->vb_vidq;
goto release_irq; video_set_drvdata(&vip->video_dev, vip);
}
vip->video_dev = &video_dev_template; ret = video_register_device(&vip->video_dev, VFL_TYPE_GRABBER, -1);
vip->video_dev->v4l2_dev = &vip->v4l2_dev;
vip->video_dev->queue = &vip->vb_vidq;
video_set_drvdata(vip->video_dev, vip);
ret = video_register_device(vip->video_dev, VFL_TYPE_GRABBER, -1);
if (ret) if (ret)
goto vrelease; goto vrelease;
...@@ -1124,13 +1118,9 @@ static int sta2x11_vip_init_one(struct pci_dev *pdev, ...@@ -1124,13 +1118,9 @@ static int sta2x11_vip_init_one(struct pci_dev *pdev,
return 0; return 0;
vunreg: vunreg:
video_set_drvdata(vip->video_dev, NULL); video_set_drvdata(&vip->video_dev, NULL);
vrelease: vrelease:
if (video_is_registered(vip->video_dev)) video_unregister_device(&vip->video_dev);
video_unregister_device(vip->video_dev);
else
video_device_release(vip->video_dev);
release_irq:
free_irq(pdev->irq, vip); free_irq(pdev->irq, vip);
release_buf: release_buf:
sta2x11_vip_release_buffer(vip); sta2x11_vip_release_buffer(vip);
...@@ -1175,9 +1165,8 @@ static void sta2x11_vip_remove_one(struct pci_dev *pdev) ...@@ -1175,9 +1165,8 @@ 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); video_unregister_device(&vip->video_dev);
/*do not call video_device_release() here, is already done */
free_irq(pdev->irq, vip); free_irq(pdev->irq, vip);
pci_disable_msi(pdev); pci_disable_msi(pdev);
vb2_queue_release(&vip->vb_vidq); vb2_queue_release(&vip->vb_vidq);
......
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