Skip to content

Commit

Permalink
[media] media: blackfin: bfin_capture: embed video_device struct in b…
Browse files Browse the repository at this point in the history
…cap_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: Lad, Prabhakar <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
prabhakarlad authored and mchehab committed Apr 2, 2015
1 parent 225ccaa commit afb7a96
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions drivers/media/platform/blackfin/bfin_capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct bcap_device {
/* v4l2 control handler */
struct v4l2_ctrl_handler ctrl_handler;
/* device node data */
struct video_device *video_dev;
struct video_device video_dev;
/* sub device instance */
struct v4l2_subdev *sd;
/* capture config */
Expand Down Expand Up @@ -809,27 +809,20 @@ static int bcap_probe(struct platform_device *pdev)
goto err_free_ppi;
}

vfd = video_device_alloc();
if (!vfd) {
ret = -ENOMEM;
v4l2_err(pdev->dev.driver, "Unable to alloc video device\n");
goto err_cleanup_ctx;
}

vfd = &bcap_dev->video_dev;
/* initialize field of video device */
vfd->release = video_device_release;
vfd->release = video_device_release_empty;
vfd->fops = &bcap_fops;
vfd->ioctl_ops = &bcap_ioctl_ops;
vfd->tvnorms = 0;
vfd->v4l2_dev = &bcap_dev->v4l2_dev;
strncpy(vfd->name, CAPTURE_DRV_NAME, sizeof(vfd->name));
bcap_dev->video_dev = vfd;

ret = v4l2_device_register(&pdev->dev, &bcap_dev->v4l2_dev);
if (ret) {
v4l2_err(pdev->dev.driver,
"Unable to register v4l2 device\n");
goto err_release_vdev;
goto err_cleanup_ctx;
}
v4l2_info(&bcap_dev->v4l2_dev, "v4l2 device registered\n");

Expand Down Expand Up @@ -868,13 +861,13 @@ static int bcap_probe(struct platform_device *pdev)
vfd->queue = q;

/* 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) {
v4l2_err(&bcap_dev->v4l2_dev,
"Unable to register video device\n");
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",
video_device_node_name(vfd));

Expand Down Expand Up @@ -952,15 +945,11 @@ static int bcap_probe(struct platform_device *pdev)
}
return 0;
err_unreg_vdev:
video_unregister_device(bcap_dev->video_dev);
bcap_dev->video_dev = NULL;
video_unregister_device(&bcap_dev->video_dev);
err_free_handler:
v4l2_ctrl_handler_free(&bcap_dev->ctrl_handler);
err_unreg_v4l2:
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:
vb2_dma_contig_cleanup_ctx(bcap_dev->alloc_ctx);
err_free_ppi:
Expand All @@ -977,7 +966,7 @@ static int bcap_remove(struct platform_device *pdev)
struct bcap_device, v4l2_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_device_unregister(v4l2_dev);
vb2_dma_contig_cleanup_ctx(bcap_dev->alloc_ctx);
Expand Down

0 comments on commit afb7a96

Please sign in to comment.