Skip to content

Commit

Permalink
[media] drivers/media/radio/radio-timb.c: use devm_ functions
Browse files Browse the repository at this point in the history
The various devm_ functions allocate memory that is released when a driver
detaches.  This patch uses these functions for data that is allocated in
the probe function of a platform device and is only freed in the remove
function.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Julia Lawall authored and Mauro Carvalho Chehab committed Aug 13, 2012
1 parent 95aeead commit 2f20c49
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions drivers/media/radio/radio-timb.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static int __devinit timbradio_probe(struct platform_device *pdev)
goto err;
}

tr = kzalloc(sizeof(*tr), GFP_KERNEL);
tr = devm_kzalloc(&pdev->dev, sizeof(*tr), GFP_KERNEL);
if (!tr) {
err = -ENOMEM;
goto err;
Expand All @@ -177,7 +177,7 @@ static int __devinit timbradio_probe(struct platform_device *pdev)
strlcpy(tr->v4l2_dev.name, DRIVER_NAME, sizeof(tr->v4l2_dev.name));
err = v4l2_device_register(NULL, &tr->v4l2_dev);
if (err)
goto err_v4l2_dev;
goto err;

tr->video_dev.v4l2_dev = &tr->v4l2_dev;

Expand All @@ -195,8 +195,6 @@ static int __devinit timbradio_probe(struct platform_device *pdev)
err_video_req:
video_device_release_empty(&tr->video_dev);
v4l2_device_unregister(&tr->v4l2_dev);
err_v4l2_dev:
kfree(tr);
err:
dev_err(&pdev->dev, "Failed to register: %d\n", err);

Expand All @@ -212,8 +210,6 @@ static int __devexit timbradio_remove(struct platform_device *pdev)

v4l2_device_unregister(&tr->v4l2_dev);

kfree(tr);

return 0;
}

Expand Down

0 comments on commit 2f20c49

Please sign in to comment.