From: Lokesh Vutla <lokeshvutla@ti.com>
Date: Mon, 5 Aug 2013 14:47:19 +0000 (+0530)
Subject: hwrng: omap - Convert to devm_kzalloc()
X-Git-Tag: firefly_0821_release~176^2~5396^2~52
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d52dc81e14c648fb1015d51c658347127d624173;p=firefly-linux-kernel-4.4.55.git

hwrng: omap - Convert to devm_kzalloc()

Use devm_kzalloc() to make cleanup paths simpler.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---

diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c
index 3e9a7ecbd5e5..9c19396b940f 100644
--- a/drivers/char/hw_random/omap-rng.c
+++ b/drivers/char/hw_random/omap-rng.c
@@ -109,7 +109,8 @@ static int omap_rng_probe(struct platform_device *pdev)
 	struct omap_rng_private_data *priv;
 	int ret;
 
-	priv = kzalloc(sizeof(struct omap_rng_private_data), GFP_KERNEL);
+	priv = devm_kzalloc(&pdev->dev, sizeof(struct omap_rng_private_data),
+			    GFP_KERNEL);
 	if (!priv) {
 		dev_err(&pdev->dev, "could not allocate memory\n");
 		return -ENOMEM;
@@ -144,8 +145,6 @@ err_register:
 	priv->base = NULL;
 	pm_runtime_disable(&pdev->dev);
 err_ioremap:
-	kfree(priv);
-
 	return ret;
 }
 
@@ -160,10 +159,6 @@ static int __exit omap_rng_remove(struct platform_device *pdev)
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
-	release_mem_region(priv->mem_res->start, resource_size(priv->mem_res));
-
-	kfree(priv);
-
 	return 0;
 }