From: Hans Verkuil Date: Mon, 9 Mar 2015 16:34:04 +0000 (-0300) Subject: [media] sta2x11: embed video_device X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4db4ca7450f97c300ebf74f5dca69015ad0d5ed3;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git [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 Cc: Federico Vaga Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c b/drivers/media/pci/sta2x11/sta2x11_vip.c index 22450f583da1..d384a6b0b09f 100644 --- a/drivers/media/pci/sta2x11/sta2x11_vip.c +++ b/drivers/media/pci/sta2x11/sta2x11_vip.c @@ -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);