aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2015-03-09 12:33:56 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-04-02 22:24:40 -0400
commit093654201e209b2a1aa59bd6c0bc1e33c1f6c4d2 (patch)
treeccfcac05937f995528da8e413eded4045046a1dd /drivers/media
parent635d62f073247e71b51167a01b84f08ff4ca000c (diff)
[media] vim2m: 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: Kamil Debski <k.debski@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/platform/vim2m.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/drivers/media/platform/vim2m.c b/drivers/media/platform/vim2m.c
index d9d844aab39b..4d6b4cc57c57 100644
--- a/drivers/media/platform/vim2m.c
+++ b/drivers/media/platform/vim2m.c
@@ -142,7 +142,7 @@ static struct vim2m_fmt *find_format(struct v4l2_format *f)
142 142
143struct vim2m_dev { 143struct vim2m_dev {
144 struct v4l2_device v4l2_dev; 144 struct v4l2_device v4l2_dev;
145 struct video_device *vfd; 145 struct video_device vfd;
146 146
147 atomic_t num_inst; 147 atomic_t num_inst;
148 struct mutex dev_mutex; 148 struct mutex dev_mutex;
@@ -968,7 +968,7 @@ static struct video_device vim2m_videodev = {
968 .fops = &vim2m_fops, 968 .fops = &vim2m_fops,
969 .ioctl_ops = &vim2m_ioctl_ops, 969 .ioctl_ops = &vim2m_ioctl_ops,
970 .minor = -1, 970 .minor = -1,
971 .release = video_device_release, 971 .release = video_device_release_empty,
972}; 972};
973 973
974static struct v4l2_m2m_ops m2m_ops = { 974static struct v4l2_m2m_ops m2m_ops = {
@@ -996,26 +996,19 @@ static int vim2m_probe(struct platform_device *pdev)
996 atomic_set(&dev->num_inst, 0); 996 atomic_set(&dev->num_inst, 0);
997 mutex_init(&dev->dev_mutex); 997 mutex_init(&dev->dev_mutex);
998 998
999 vfd = video_device_alloc(); 999 dev->vfd = vim2m_videodev;
1000 if (!vfd) { 1000 vfd = &dev->vfd;
1001 v4l2_err(&dev->v4l2_dev, "Failed to allocate video device\n");
1002 ret = -ENOMEM;
1003 goto unreg_dev;
1004 }
1005
1006 *vfd = vim2m_videodev;
1007 vfd->lock = &dev->dev_mutex; 1001 vfd->lock = &dev->dev_mutex;
1008 vfd->v4l2_dev = &dev->v4l2_dev; 1002 vfd->v4l2_dev = &dev->v4l2_dev;
1009 1003
1010 ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0); 1004 ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
1011 if (ret) { 1005 if (ret) {
1012 v4l2_err(&dev->v4l2_dev, "Failed to register video device\n"); 1006 v4l2_err(&dev->v4l2_dev, "Failed to register video device\n");
1013 goto rel_vdev; 1007 goto unreg_dev;
1014 } 1008 }
1015 1009
1016 video_set_drvdata(vfd, dev); 1010 video_set_drvdata(vfd, dev);
1017 snprintf(vfd->name, sizeof(vfd->name), "%s", vim2m_videodev.name); 1011 snprintf(vfd->name, sizeof(vfd->name), "%s", vim2m_videodev.name);
1018 dev->vfd = vfd;
1019 v4l2_info(&dev->v4l2_dev, 1012 v4l2_info(&dev->v4l2_dev,
1020 "Device registered as /dev/video%d\n", vfd->num); 1013 "Device registered as /dev/video%d\n", vfd->num);
1021 1014
@@ -1033,9 +1026,7 @@ static int vim2m_probe(struct platform_device *pdev)
1033 1026
1034err_m2m: 1027err_m2m:
1035 v4l2_m2m_release(dev->m2m_dev); 1028 v4l2_m2m_release(dev->m2m_dev);
1036 video_unregister_device(dev->vfd); 1029 video_unregister_device(&dev->vfd);
1037rel_vdev:
1038 video_device_release(vfd);
1039unreg_dev: 1030unreg_dev:
1040 v4l2_device_unregister(&dev->v4l2_dev); 1031 v4l2_device_unregister(&dev->v4l2_dev);
1041 1032
@@ -1049,7 +1040,7 @@ static int vim2m_remove(struct platform_device *pdev)
1049 v4l2_info(&dev->v4l2_dev, "Removing " MEM2MEM_NAME); 1040 v4l2_info(&dev->v4l2_dev, "Removing " MEM2MEM_NAME);
1050 v4l2_m2m_release(dev->m2m_dev); 1041 v4l2_m2m_release(dev->m2m_dev);
1051 del_timer_sync(&dev->timer); 1042 del_timer_sync(&dev->timer);
1052 video_unregister_device(dev->vfd); 1043 video_unregister_device(&dev->vfd);
1053 v4l2_device_unregister(&dev->v4l2_dev); 1044 v4l2_device_unregister(&dev->v4l2_dev);
1054 1045
1055 return 0; 1046 return 0;