Commit afb7a966 authored by Lad, Prabhakar's avatar Lad, Prabhakar Committed by Mauro Carvalho Chehab

[media] media: blackfin: bfin_capture: embed video_device struct in bcap_device

Embed video_device struct (video_dev) in bcap_device and
Unregister path doesn't need to free the video_device
structure, hence, change the video_device.release callback
point to video_device_release_empty.
Signed-off-by: default avatarLad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 225ccaa3
...@@ -64,7 +64,7 @@ struct bcap_device { ...@@ -64,7 +64,7 @@ struct bcap_device {
/* v4l2 control handler */ /* v4l2 control handler */
struct v4l2_ctrl_handler ctrl_handler; struct v4l2_ctrl_handler ctrl_handler;
/* device node data */ /* device node data */
struct video_device *video_dev; struct video_device video_dev;
/* sub device instance */ /* sub device instance */
struct v4l2_subdev *sd; struct v4l2_subdev *sd;
/* capture config */ /* capture config */
...@@ -809,27 +809,20 @@ static int bcap_probe(struct platform_device *pdev) ...@@ -809,27 +809,20 @@ static int bcap_probe(struct platform_device *pdev)
goto err_free_ppi; goto err_free_ppi;
} }
vfd = video_device_alloc(); vfd = &bcap_dev->video_dev;
if (!vfd) {
ret = -ENOMEM;
v4l2_err(pdev->dev.driver, "Unable to alloc video device\n");
goto err_cleanup_ctx;
}
/* initialize field of video device */ /* initialize field of video device */
vfd->release = video_device_release; vfd->release = video_device_release_empty;
vfd->fops = &bcap_fops; vfd->fops = &bcap_fops;
vfd->ioctl_ops = &bcap_ioctl_ops; vfd->ioctl_ops = &bcap_ioctl_ops;
vfd->tvnorms = 0; vfd->tvnorms = 0;
vfd->v4l2_dev = &bcap_dev->v4l2_dev; vfd->v4l2_dev = &bcap_dev->v4l2_dev;
strncpy(vfd->name, CAPTURE_DRV_NAME, sizeof(vfd->name)); strncpy(vfd->name, CAPTURE_DRV_NAME, sizeof(vfd->name));
bcap_dev->video_dev = vfd;
ret = v4l2_device_register(&pdev->dev, &bcap_dev->v4l2_dev); ret = v4l2_device_register(&pdev->dev, &bcap_dev->v4l2_dev);
if (ret) { if (ret) {
v4l2_err(pdev->dev.driver, v4l2_err(pdev->dev.driver,
"Unable to register v4l2 device\n"); "Unable to register v4l2 device\n");
goto err_release_vdev; goto err_cleanup_ctx;
} }
v4l2_info(&bcap_dev->v4l2_dev, "v4l2 device registered\n"); v4l2_info(&bcap_dev->v4l2_dev, "v4l2 device registered\n");
...@@ -868,13 +861,13 @@ static int bcap_probe(struct platform_device *pdev) ...@@ -868,13 +861,13 @@ static int bcap_probe(struct platform_device *pdev)
vfd->queue = q; vfd->queue = q;
/* register video device */ /* register video device */
ret = video_register_device(bcap_dev->video_dev, VFL_TYPE_GRABBER, -1); ret = video_register_device(&bcap_dev->video_dev, VFL_TYPE_GRABBER, -1);
if (ret) { if (ret) {
v4l2_err(&bcap_dev->v4l2_dev, v4l2_err(&bcap_dev->v4l2_dev,
"Unable to register video device\n"); "Unable to register video device\n");
goto err_free_handler; goto err_free_handler;
} }
video_set_drvdata(bcap_dev->video_dev, bcap_dev); video_set_drvdata(&bcap_dev->video_dev, bcap_dev);
v4l2_info(&bcap_dev->v4l2_dev, "video device registered as: %s\n", v4l2_info(&bcap_dev->v4l2_dev, "video device registered as: %s\n",
video_device_node_name(vfd)); video_device_node_name(vfd));
...@@ -952,15 +945,11 @@ static int bcap_probe(struct platform_device *pdev) ...@@ -952,15 +945,11 @@ static int bcap_probe(struct platform_device *pdev)
} }
return 0; return 0;
err_unreg_vdev: err_unreg_vdev:
video_unregister_device(bcap_dev->video_dev); video_unregister_device(&bcap_dev->video_dev);
bcap_dev->video_dev = NULL;
err_free_handler: err_free_handler:
v4l2_ctrl_handler_free(&bcap_dev->ctrl_handler); v4l2_ctrl_handler_free(&bcap_dev->ctrl_handler);
err_unreg_v4l2: err_unreg_v4l2:
v4l2_device_unregister(&bcap_dev->v4l2_dev); v4l2_device_unregister(&bcap_dev->v4l2_dev);
err_release_vdev:
if (bcap_dev->video_dev)
video_device_release(bcap_dev->video_dev);
err_cleanup_ctx: err_cleanup_ctx:
vb2_dma_contig_cleanup_ctx(bcap_dev->alloc_ctx); vb2_dma_contig_cleanup_ctx(bcap_dev->alloc_ctx);
err_free_ppi: err_free_ppi:
...@@ -977,7 +966,7 @@ static int bcap_remove(struct platform_device *pdev) ...@@ -977,7 +966,7 @@ static int bcap_remove(struct platform_device *pdev)
struct bcap_device, v4l2_dev); struct bcap_device, v4l2_dev);
bcap_free_sensor_formats(bcap_dev); bcap_free_sensor_formats(bcap_dev);
video_unregister_device(bcap_dev->video_dev); video_unregister_device(&bcap_dev->video_dev);
v4l2_ctrl_handler_free(&bcap_dev->ctrl_handler); v4l2_ctrl_handler_free(&bcap_dev->ctrl_handler);
v4l2_device_unregister(v4l2_dev); v4l2_device_unregister(v4l2_dev);
vb2_dma_contig_cleanup_ctx(bcap_dev->alloc_ctx); vb2_dma_contig_cleanup_ctx(bcap_dev->alloc_ctx);
......
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