Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 28e9cc80 authored by Julia Lawall's avatar Julia Lawall Committed by Mauro Carvalho Chehab
Browse files

[media] drivers/media/radio/radio-si4713.c: use devm_ functions



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: default avatarJulia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent d91e0139
Loading
Loading
Loading
Loading
+2 −5
Original line number Original line Diff line number Diff line
@@ -268,7 +268,7 @@ static int radio_si4713_pdriver_probe(struct platform_device *pdev)
		goto exit;
		goto exit;
	}
	}


	rsdev = kzalloc(sizeof *rsdev, GFP_KERNEL);
	rsdev = devm_kzalloc(&pdev->dev, sizeof(*rsdev), GFP_KERNEL);
	if (!rsdev) {
	if (!rsdev) {
		dev_err(&pdev->dev, "Failed to alloc video device.\n");
		dev_err(&pdev->dev, "Failed to alloc video device.\n");
		rval = -ENOMEM;
		rval = -ENOMEM;
@@ -278,7 +278,7 @@ static int radio_si4713_pdriver_probe(struct platform_device *pdev)
	rval = v4l2_device_register(&pdev->dev, &rsdev->v4l2_dev);
	rval = v4l2_device_register(&pdev->dev, &rsdev->v4l2_dev);
	if (rval) {
	if (rval) {
		dev_err(&pdev->dev, "Failed to register v4l2 device.\n");
		dev_err(&pdev->dev, "Failed to register v4l2 device.\n");
		goto free_rsdev;
		goto exit;
	}
	}


	adapter = i2c_get_adapter(pdata->i2c_bus);
	adapter = i2c_get_adapter(pdata->i2c_bus);
@@ -322,8 +322,6 @@ static int radio_si4713_pdriver_probe(struct platform_device *pdev)
	i2c_put_adapter(adapter);
	i2c_put_adapter(adapter);
unregister_v4l2_dev:
unregister_v4l2_dev:
	v4l2_device_unregister(&rsdev->v4l2_dev);
	v4l2_device_unregister(&rsdev->v4l2_dev);
free_rsdev:
	kfree(rsdev);
exit:
exit:
	return rval;
	return rval;
}
}
@@ -342,7 +340,6 @@ static int __exit radio_si4713_pdriver_remove(struct platform_device *pdev)
	video_unregister_device(rsdev->radio_dev);
	video_unregister_device(rsdev->radio_dev);
	i2c_put_adapter(client->adapter);
	i2c_put_adapter(client->adapter);
	v4l2_device_unregister(&rsdev->v4l2_dev);
	v4l2_device_unregister(&rsdev->v4l2_dev);
	kfree(rsdev);


	return 0;
	return 0;
}
}