Commit 70bd97ae authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] vivi: embed struct video_device instead of allocating it

Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 4e1d2ac6
...@@ -188,6 +188,7 @@ struct vivi_dev { ...@@ -188,6 +188,7 @@ struct vivi_dev {
struct list_head vivi_devlist; struct list_head vivi_devlist;
struct v4l2_device v4l2_dev; struct v4l2_device v4l2_dev;
struct v4l2_ctrl_handler ctrl_handler; struct v4l2_ctrl_handler ctrl_handler;
struct video_device vdev;
/* controls */ /* controls */
struct v4l2_ctrl *brightness; struct v4l2_ctrl *brightness;
...@@ -213,9 +214,6 @@ struct vivi_dev { ...@@ -213,9 +214,6 @@ struct vivi_dev {
spinlock_t slock; spinlock_t slock;
struct mutex mutex; struct mutex mutex;
/* various device info */
struct video_device *vfd;
struct vivi_dmaqueue vidq; struct vivi_dmaqueue vidq;
/* Several counters */ /* Several counters */
...@@ -1326,7 +1324,7 @@ static struct video_device vivi_template = { ...@@ -1326,7 +1324,7 @@ static struct video_device vivi_template = {
.name = "vivi", .name = "vivi",
.fops = &vivi_fops, .fops = &vivi_fops,
.ioctl_ops = &vivi_ioctl_ops, .ioctl_ops = &vivi_ioctl_ops,
.release = video_device_release, .release = video_device_release_empty,
}; };
/* ----------------------------------------------------------------- /* -----------------------------------------------------------------
...@@ -1344,8 +1342,8 @@ static int vivi_release(void) ...@@ -1344,8 +1342,8 @@ static int vivi_release(void)
dev = list_entry(list, struct vivi_dev, vivi_devlist); dev = list_entry(list, struct vivi_dev, vivi_devlist);
v4l2_info(&dev->v4l2_dev, "unregistering %s\n", v4l2_info(&dev->v4l2_dev, "unregistering %s\n",
video_device_node_name(dev->vfd)); video_device_node_name(&dev->vdev));
video_unregister_device(dev->vfd); video_unregister_device(&dev->vdev);
v4l2_device_unregister(&dev->v4l2_dev); v4l2_device_unregister(&dev->v4l2_dev);
v4l2_ctrl_handler_free(&dev->ctrl_handler); v4l2_ctrl_handler_free(&dev->ctrl_handler);
kfree(dev); kfree(dev);
...@@ -1430,11 +1428,7 @@ static int __init vivi_create_instance(int inst) ...@@ -1430,11 +1428,7 @@ static int __init vivi_create_instance(int inst)
INIT_LIST_HEAD(&dev->vidq.active); INIT_LIST_HEAD(&dev->vidq.active);
init_waitqueue_head(&dev->vidq.wq); init_waitqueue_head(&dev->vidq.wq);
ret = -ENOMEM; vfd = &dev->vdev;
vfd = video_device_alloc();
if (!vfd)
goto unreg_dev;
*vfd = vivi_template; *vfd = vivi_template;
vfd->debug = debug; vfd->debug = debug;
vfd->v4l2_dev = &dev->v4l2_dev; vfd->v4l2_dev = &dev->v4l2_dev;
...@@ -1445,12 +1439,11 @@ static int __init vivi_create_instance(int inst) ...@@ -1445,12 +1439,11 @@ static int __init vivi_create_instance(int inst)
* all fops and v4l2 ioctls. * all fops and v4l2 ioctls.
*/ */
vfd->lock = &dev->mutex; vfd->lock = &dev->mutex;
video_set_drvdata(vfd, dev);
ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr); ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr);
if (ret < 0) if (ret < 0)
goto rel_vdev; goto unreg_dev;
video_set_drvdata(vfd, dev);
/* Now that everything is fine, let's add it to device list */ /* Now that everything is fine, let's add it to device list */
list_add_tail(&dev->vivi_devlist, &vivi_devlist); list_add_tail(&dev->vivi_devlist, &vivi_devlist);
...@@ -1458,13 +1451,10 @@ static int __init vivi_create_instance(int inst) ...@@ -1458,13 +1451,10 @@ static int __init vivi_create_instance(int inst)
if (video_nr != -1) if (video_nr != -1)
video_nr++; video_nr++;
dev->vfd = vfd;
v4l2_info(&dev->v4l2_dev, "V4L2 device registered as %s\n", v4l2_info(&dev->v4l2_dev, "V4L2 device registered as %s\n",
video_device_node_name(vfd)); video_device_node_name(vfd));
return 0; return 0;
rel_vdev:
video_device_release(vfd);
unreg_dev: unreg_dev:
v4l2_ctrl_handler_free(hdl); v4l2_ctrl_handler_free(hdl);
v4l2_device_unregister(&dev->v4l2_dev); v4l2_device_unregister(&dev->v4l2_dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment