Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
09365420 635d62f0

+7 -16
+7 -16
drivers/media/platform/vim2m.c
··· 142 142 143 143 struct vim2m_dev { 144 144 struct v4l2_device v4l2_dev; 145 - struct video_device *vfd; 145 + struct video_device vfd; 146 146 147 147 atomic_t num_inst; 148 148 struct mutex dev_mutex; ··· 968 968 .fops = &vim2m_fops, 969 969 .ioctl_ops = &vim2m_ioctl_ops, 970 970 .minor = -1, 971 - .release = video_device_release, 971 + .release = video_device_release_empty, 972 972 }; 973 973 974 974 static struct v4l2_m2m_ops m2m_ops = { ··· 996 996 atomic_set(&dev->num_inst, 0); 997 997 mutex_init(&dev->dev_mutex); 998 998 999 - vfd = video_device_alloc(); 1000 - if (!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; 999 + dev->vfd = vim2m_videodev; 1000 + vfd = &dev->vfd; 1007 1001 vfd->lock = &dev->dev_mutex; 1008 1002 vfd->v4l2_dev = &dev->v4l2_dev; 1009 1003 1010 1004 ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0); 1011 1005 if (ret) { 1012 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 1010 video_set_drvdata(vfd, dev); 1017 1011 snprintf(vfd->name, sizeof(vfd->name), "%s", vim2m_videodev.name); 1018 - dev->vfd = vfd; 1019 1012 v4l2_info(&dev->v4l2_dev, 1020 1013 "Device registered as /dev/video%d\n", vfd->num); 1021 1014 ··· 1026 1033 1027 1034 err_m2m: 1028 1035 v4l2_m2m_release(dev->m2m_dev); 1029 - video_unregister_device(dev->vfd); 1030 - rel_vdev: 1031 - video_device_release(vfd); 1036 + video_unregister_device(&dev->vfd); 1032 1037 unreg_dev: 1033 1038 v4l2_device_unregister(&dev->v4l2_dev); 1034 1039 ··· 1040 1049 v4l2_info(&dev->v4l2_dev, "Removing " MEM2MEM_NAME); 1041 1050 v4l2_m2m_release(dev->m2m_dev); 1042 1051 del_timer_sync(&dev->timer); 1043 - video_unregister_device(dev->vfd); 1052 + video_unregister_device(&dev->vfd); 1044 1053 v4l2_device_unregister(&dev->v4l2_dev); 1045 1054 1046 1055 return 0;