aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-04-08 05:11:12 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-04-14 18:49:25 -0400
commitfdf51599c0fca3dc1e45924b71e09a862f34ec78 (patch)
tree991e99b75430203b86e808b839896c44a93ae5d9 /drivers/media/radio
parent91e20e81087c990f3f9c0074ed740e63c666071b (diff)
[media] radio-si4713: embed struct video_device instead of allocating it
Also set the v4l2_dev pointer in struct video_device as this was missing. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Eduardo Valentin <edubezval@gmail.com> Tested-by: Eduardo Valentin <edubezval@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/radio')
-rw-r--r--drivers/media/radio/radio-si4713.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/drivers/media/radio/radio-si4713.c b/drivers/media/radio/radio-si4713.c
index 320f3012c850..70dc6527a12c 100644
--- a/drivers/media/radio/radio-si4713.c
+++ b/drivers/media/radio/radio-si4713.c
@@ -48,7 +48,7 @@ MODULE_ALIAS("platform:radio-si4713");
48/* Driver state struct */ 48/* Driver state struct */
49struct radio_si4713_device { 49struct radio_si4713_device {
50 struct v4l2_device v4l2_dev; 50 struct v4l2_device v4l2_dev;
51 struct video_device *radio_dev; 51 struct video_device radio_dev;
52}; 52};
53 53
54/* radio_si4713_fops - file operations interface */ 54/* radio_si4713_fops - file operations interface */
@@ -217,7 +217,7 @@ static struct v4l2_ioctl_ops radio_si4713_ioctl_ops = {
217static struct video_device radio_si4713_vdev_template = { 217static struct video_device radio_si4713_vdev_template = {
218 .fops = &radio_si4713_fops, 218 .fops = &radio_si4713_fops,
219 .name = "radio-si4713", 219 .name = "radio-si4713",
220 .release = video_device_release, 220 .release = video_device_release_empty,
221 .ioctl_ops = &radio_si4713_ioctl_ops, 221 .ioctl_ops = &radio_si4713_ioctl_ops,
222 .vfl_dir = VFL_DIR_TX, 222 .vfl_dir = VFL_DIR_TX,
223}; 223};
@@ -267,27 +267,18 @@ static int radio_si4713_pdriver_probe(struct platform_device *pdev)
267 goto put_adapter; 267 goto put_adapter;
268 } 268 }
269 269
270 rsdev->radio_dev = video_device_alloc(); 270 rsdev->radio_dev = radio_si4713_vdev_template;
271 if (!rsdev->radio_dev) { 271 rsdev->radio_dev.v4l2_dev = &rsdev->v4l2_dev;
272 dev_err(&pdev->dev, "Failed to alloc video device.\n"); 272 video_set_drvdata(&rsdev->radio_dev, rsdev);
273 rval = -ENOMEM; 273 if (video_register_device(&rsdev->radio_dev, VFL_TYPE_RADIO, radio_nr)) {
274 goto put_adapter;
275 }
276
277 memcpy(rsdev->radio_dev, &radio_si4713_vdev_template,
278 sizeof(radio_si4713_vdev_template));
279 video_set_drvdata(rsdev->radio_dev, rsdev);
280 if (video_register_device(rsdev->radio_dev, VFL_TYPE_RADIO, radio_nr)) {
281 dev_err(&pdev->dev, "Could not register video device.\n"); 274 dev_err(&pdev->dev, "Could not register video device.\n");
282 rval = -EIO; 275 rval = -EIO;
283 goto free_vdev; 276 goto put_adapter;
284 } 277 }
285 dev_info(&pdev->dev, "New device successfully probed\n"); 278 dev_info(&pdev->dev, "New device successfully probed\n");
286 279
287 goto exit; 280 goto exit;
288 281
289free_vdev:
290 video_device_release(rsdev->radio_dev);
291put_adapter: 282put_adapter:
292 i2c_put_adapter(adapter); 283 i2c_put_adapter(adapter);
293unregister_v4l2_dev: 284unregister_v4l2_dev:
@@ -306,7 +297,7 @@ static int radio_si4713_pdriver_remove(struct platform_device *pdev)
306 struct radio_si4713_device *rsdev; 297 struct radio_si4713_device *rsdev;
307 298
308 rsdev = container_of(v4l2_dev, struct radio_si4713_device, v4l2_dev); 299 rsdev = container_of(v4l2_dev, struct radio_si4713_device, v4l2_dev);
309 video_unregister_device(rsdev->radio_dev); 300 video_unregister_device(&rsdev->radio_dev);
310 i2c_put_adapter(client->adapter); 301 i2c_put_adapter(client->adapter);
311 v4l2_device_unregister(&rsdev->v4l2_dev); 302 v4l2_device_unregister(&rsdev->v4l2_dev);
312 303