mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 17:30:02 +00:00
[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: Hans Verkuil <hans.verkuil@cisco.com> Cc: Federico Vaga <federico.vaga@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
This commit is contained in:
parent
d079f99f00
commit
4db4ca7450
1 changed files with 12 additions and 23 deletions
|
@ -127,7 +127,7 @@ static inline struct vip_buffer *to_vip_buffer(struct vb2_buffer *vb2)
|
|||
*/
|
||||
struct sta2x11_vip {
|
||||
struct v4l2_device v4l2_dev;
|
||||
struct video_device *video_dev;
|
||||
struct video_device video_dev;
|
||||
struct pci_dev *pdev;
|
||||
struct i2c_adapter *adapter;
|
||||
unsigned int register_save_area[IRQ_COUNT + SAVE_COUNT + AUX_COUNT];
|
||||
|
@ -763,7 +763,7 @@ static const struct v4l2_ioctl_ops vip_ioctl_ops = {
|
|||
|
||||
static struct video_device video_dev_template = {
|
||||
.name = KBUILD_MODNAME,
|
||||
.release = video_device_release,
|
||||
.release = video_device_release_empty,
|
||||
.fops = &vip_fops,
|
||||
.ioctl_ops = &vip_ioctl_ops,
|
||||
.tvnorms = V4L2_STD_ALL,
|
||||
|
@ -1082,19 +1082,13 @@ static int sta2x11_vip_init_one(struct pci_dev *pdev,
|
|||
goto release_buf;
|
||||
}
|
||||
|
||||
/* Alloc, initialize and register video device */
|
||||
vip->video_dev = video_device_alloc();
|
||||
if (!vip->video_dev) {
|
||||
ret = -ENOMEM;
|
||||
goto release_irq;
|
||||
}
|
||||
/* Initialize and register video device */
|
||||
vip->video_dev = video_dev_template;
|
||||
vip->video_dev.v4l2_dev = &vip->v4l2_dev;
|
||||
vip->video_dev.queue = &vip->vb_vidq;
|
||||
video_set_drvdata(&vip->video_dev, vip);
|
||||
|
||||
vip->video_dev = &video_dev_template;
|
||||
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);
|
||||
ret = video_register_device(&vip->video_dev, VFL_TYPE_GRABBER, -1);
|
||||
if (ret)
|
||||
goto vrelease;
|
||||
|
||||
|
@ -1124,13 +1118,9 @@ static int sta2x11_vip_init_one(struct pci_dev *pdev,
|
|||
return 0;
|
||||
|
||||
vunreg:
|
||||
video_set_drvdata(vip->video_dev, NULL);
|
||||
video_set_drvdata(&vip->video_dev, NULL);
|
||||
vrelease:
|
||||
if (video_is_registered(vip->video_dev))
|
||||
video_unregister_device(vip->video_dev);
|
||||
else
|
||||
video_device_release(vip->video_dev);
|
||||
release_irq:
|
||||
video_unregister_device(&vip->video_dev);
|
||||
free_irq(pdev->irq, vip);
|
||||
release_buf:
|
||||
sta2x11_vip_release_buffer(vip);
|
||||
|
@ -1175,9 +1165,8 @@ static void sta2x11_vip_remove_one(struct pci_dev *pdev)
|
|||
|
||||
sta2x11_vip_clear_register(vip);
|
||||
|
||||
video_set_drvdata(vip->video_dev, NULL);
|
||||
video_unregister_device(vip->video_dev);
|
||||
/*do not call video_device_release() here, is already done */
|
||||
video_set_drvdata(&vip->video_dev, NULL);
|
||||
video_unregister_device(&vip->video_dev);
|
||||
free_irq(pdev->irq, vip);
|
||||
pci_disable_msi(pdev);
|
||||
vb2_queue_release(&vip->vb_vidq);
|
||||
|
|
Loading…
Reference in a new issue