aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-06-09 10:27:43 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-07-06 16:32:44 -0400
commit70bd97ae5f12299b152d4220cfc77d8078b21d35 (patch)
tree153c51a675cb1ebe76e97286f19610637069428c /drivers
parent4e1d2ac63368843d63dc38ed42f141506bd1e988 (diff)
[media] vivi: embed struct video_device instead of allocating it
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/vivi.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index e00efcf02571..1e4da5e43a32 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -188,6 +188,7 @@ struct vivi_dev {
188 struct list_head vivi_devlist; 188 struct list_head vivi_devlist;
189 struct v4l2_device v4l2_dev; 189 struct v4l2_device v4l2_dev;
190 struct v4l2_ctrl_handler ctrl_handler; 190 struct v4l2_ctrl_handler ctrl_handler;
191 struct video_device vdev;
191 192
192 /* controls */ 193 /* controls */
193 struct v4l2_ctrl *brightness; 194 struct v4l2_ctrl *brightness;
@@ -213,9 +214,6 @@ struct vivi_dev {
213 spinlock_t slock; 214 spinlock_t slock;
214 struct mutex mutex; 215 struct mutex mutex;
215 216
216 /* various device info */
217 struct video_device *vfd;
218
219 struct vivi_dmaqueue vidq; 217 struct vivi_dmaqueue vidq;
220 218
221 /* Several counters */ 219 /* Several counters */
@@ -1326,7 +1324,7 @@ static struct video_device vivi_template = {
1326 .name = "vivi", 1324 .name = "vivi",
1327 .fops = &vivi_fops, 1325 .fops = &vivi_fops,
1328 .ioctl_ops = &vivi_ioctl_ops, 1326 .ioctl_ops = &vivi_ioctl_ops,
1329 .release = video_device_release, 1327 .release = video_device_release_empty,
1330}; 1328};
1331 1329
1332/* ----------------------------------------------------------------- 1330/* -----------------------------------------------------------------
@@ -1344,8 +1342,8 @@ static int vivi_release(void)
1344 dev = list_entry(list, struct vivi_dev, vivi_devlist); 1342 dev = list_entry(list, struct vivi_dev, vivi_devlist);
1345 1343
1346 v4l2_info(&dev->v4l2_dev, "unregistering %s\n", 1344 v4l2_info(&dev->v4l2_dev, "unregistering %s\n",
1347 video_device_node_name(dev->vfd)); 1345 video_device_node_name(&dev->vdev));
1348 video_unregister_device(dev->vfd); 1346 video_unregister_device(&dev->vdev);
1349 v4l2_device_unregister(&dev->v4l2_dev); 1347 v4l2_device_unregister(&dev->v4l2_dev);
1350 v4l2_ctrl_handler_free(&dev->ctrl_handler); 1348 v4l2_ctrl_handler_free(&dev->ctrl_handler);
1351 kfree(dev); 1349 kfree(dev);
@@ -1430,11 +1428,7 @@ static int __init vivi_create_instance(int inst)
1430 INIT_LIST_HEAD(&dev->vidq.active); 1428 INIT_LIST_HEAD(&dev->vidq.active);
1431 init_waitqueue_head(&dev->vidq.wq); 1429 init_waitqueue_head(&dev->vidq.wq);
1432 1430
1433 ret = -ENOMEM; 1431 vfd = &dev->vdev;
1434 vfd = video_device_alloc();
1435 if (!vfd)
1436 goto unreg_dev;
1437
1438 *vfd = vivi_template; 1432 *vfd = vivi_template;
1439 vfd->debug = debug; 1433 vfd->debug = debug;
1440 vfd->v4l2_dev = &dev->v4l2_dev; 1434 vfd->v4l2_dev = &dev->v4l2_dev;
@@ -1445,12 +1439,11 @@ static int __init vivi_create_instance(int inst)
1445 * all fops and v4l2 ioctls. 1439 * all fops and v4l2 ioctls.
1446 */ 1440 */
1447 vfd->lock = &dev->mutex; 1441 vfd->lock = &dev->mutex;
1442 video_set_drvdata(vfd, dev);
1448 1443
1449 ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr); 1444 ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr);
1450 if (ret < 0) 1445 if (ret < 0)
1451 goto rel_vdev; 1446 goto unreg_dev;
1452
1453 video_set_drvdata(vfd, dev);
1454 1447
1455 /* Now that everything is fine, let's add it to device list */ 1448 /* Now that everything is fine, let's add it to device list */
1456 list_add_tail(&dev->vivi_devlist, &vivi_devlist); 1449 list_add_tail(&dev->vivi_devlist, &vivi_devlist);
@@ -1458,13 +1451,10 @@ static int __init vivi_create_instance(int inst)
1458 if (video_nr != -1) 1451 if (video_nr != -1)
1459 video_nr++; 1452 video_nr++;
1460 1453
1461 dev->vfd = vfd;
1462 v4l2_info(&dev->v4l2_dev, "V4L2 device registered as %s\n", 1454 v4l2_info(&dev->v4l2_dev, "V4L2 device registered as %s\n",
1463 video_device_node_name(vfd)); 1455 video_device_node_name(vfd));
1464 return 0; 1456 return 0;
1465 1457
1466rel_vdev:
1467 video_device_release(vfd);
1468unreg_dev: 1458unreg_dev:
1469 v4l2_ctrl_handler_free(hdl); 1459 v4l2_ctrl_handler_free(hdl);
1470 v4l2_device_unregister(&dev->v4l2_dev); 1460 v4l2_device_unregister(&dev->v4l2_dev);