diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2015-03-09 12:34:04 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-04-02 22:56:44 -0400 |
commit | 4db4ca7450f97c300ebf74f5dca69015ad0d5ed3 (patch) | |
tree | 9185f5540400ebe8049f0273965d96364c6bb227 /drivers/media/pci | |
parent | d079f99f00f75065feb0c33cd7c7b8e4d224d3c9 (diff) |
[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>
Diffstat (limited to 'drivers/media/pci')
-rw-r--r-- | drivers/media/pci/sta2x11/sta2x11_vip.c | 35 |
1 files changed, 12 insertions, 23 deletions
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) | |||
127 | */ | 127 | */ |
128 | struct sta2x11_vip { | 128 | struct sta2x11_vip { |
129 | struct v4l2_device v4l2_dev; | 129 | struct v4l2_device v4l2_dev; |
130 | struct video_device *video_dev; | 130 | struct video_device video_dev; |
131 | struct pci_dev *pdev; | 131 | struct pci_dev *pdev; |
132 | struct i2c_adapter *adapter; | 132 | struct i2c_adapter *adapter; |
133 | unsigned int register_save_area[IRQ_COUNT + SAVE_COUNT + AUX_COUNT]; | 133 | 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 | 763 | ||
764 | static struct video_device video_dev_template = { | 764 | static struct video_device video_dev_template = { |
765 | .name = KBUILD_MODNAME, | 765 | .name = KBUILD_MODNAME, |
766 | .release = video_device_release, | 766 | .release = video_device_release_empty, |
767 | .fops = &vip_fops, | 767 | .fops = &vip_fops, |
768 | .ioctl_ops = &vip_ioctl_ops, | 768 | .ioctl_ops = &vip_ioctl_ops, |
769 | .tvnorms = V4L2_STD_ALL, | 769 | .tvnorms = V4L2_STD_ALL, |
@@ -1082,19 +1082,13 @@ static int sta2x11_vip_init_one(struct pci_dev *pdev, | |||
1082 | goto release_buf; | 1082 | goto release_buf; |
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | /* Alloc, initialize and register video device */ | 1085 | /* Initialize and register video device */ |
1086 | vip->video_dev = video_device_alloc(); | 1086 | vip->video_dev = video_dev_template; |
1087 | if (!vip->video_dev) { | 1087 | vip->video_dev.v4l2_dev = &vip->v4l2_dev; |
1088 | ret = -ENOMEM; | 1088 | vip->video_dev.queue = &vip->vb_vidq; |
1089 | goto release_irq; | 1089 | video_set_drvdata(&vip->video_dev, vip); |
1090 | } | ||
1091 | 1090 | ||
1092 | vip->video_dev = &video_dev_template; | 1091 | ret = video_register_device(&vip->video_dev, VFL_TYPE_GRABBER, -1); |
1093 | vip->video_dev->v4l2_dev = &vip->v4l2_dev; | ||
1094 | vip->video_dev->queue = &vip->vb_vidq; | ||
1095 | video_set_drvdata(vip->video_dev, vip); | ||
1096 | |||
1097 | ret = video_register_device(vip->video_dev, VFL_TYPE_GRABBER, -1); | ||
1098 | if (ret) | 1092 | if (ret) |
1099 | goto vrelease; | 1093 | goto vrelease; |
1100 | 1094 | ||
@@ -1124,13 +1118,9 @@ static int sta2x11_vip_init_one(struct pci_dev *pdev, | |||
1124 | return 0; | 1118 | return 0; |
1125 | 1119 | ||
1126 | vunreg: | 1120 | vunreg: |
1127 | video_set_drvdata(vip->video_dev, NULL); | 1121 | video_set_drvdata(&vip->video_dev, NULL); |
1128 | vrelease: | 1122 | vrelease: |
1129 | if (video_is_registered(vip->video_dev)) | 1123 | video_unregister_device(&vip->video_dev); |
1130 | video_unregister_device(vip->video_dev); | ||
1131 | else | ||
1132 | video_device_release(vip->video_dev); | ||
1133 | release_irq: | ||
1134 | free_irq(pdev->irq, vip); | 1124 | free_irq(pdev->irq, vip); |
1135 | release_buf: | 1125 | release_buf: |
1136 | sta2x11_vip_release_buffer(vip); | 1126 | sta2x11_vip_release_buffer(vip); |
@@ -1175,9 +1165,8 @@ static void sta2x11_vip_remove_one(struct pci_dev *pdev) | |||
1175 | 1165 | ||
1176 | sta2x11_vip_clear_register(vip); | 1166 | sta2x11_vip_clear_register(vip); |
1177 | 1167 | ||
1178 | video_set_drvdata(vip->video_dev, NULL); | 1168 | video_set_drvdata(&vip->video_dev, NULL); |
1179 | video_unregister_device(vip->video_dev); | 1169 | video_unregister_device(&vip->video_dev); |
1180 | /*do not call video_device_release() here, is already done */ | ||
1181 | free_irq(pdev->irq, vip); | 1170 | free_irq(pdev->irq, vip); |
1182 | pci_disable_msi(pdev); | 1171 | pci_disable_msi(pdev); |
1183 | vb2_queue_release(&vip->vb_vidq); | 1172 | vb2_queue_release(&vip->vb_vidq); |