mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laxman Dewangan <ldewangan@nvidia.com>
To: <lrg@ti.com>, <broonie@opensource.wolfsonmicro.com>
Cc: <linux-kernel@vger.kernel.org>, Laxman Dewangan <ldewangan@nvidia.com>
Subject: [PATCH 4/5] regulator: tps65910: use devm_* for memory allocation
Date: Sat, 19 May 2012 20:04:09 +0530	[thread overview]
Message-ID: <1337438050-3707-5-git-send-email-ldewangan@nvidia.com> (raw)
In-Reply-To: <1337438050-3707-1-git-send-email-ldewangan@nvidia.com>

use the devm_* apis for memory allocation.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
 drivers/regulator/tps65910-regulator.c |   27 +++++++++------------------
 1 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c
index 72942c2..5a8ad4e 100644
--- a/drivers/regulator/tps65910-regulator.c
+++ b/drivers/regulator/tps65910-regulator.c
@@ -1191,25 +1191,25 @@ static __devinit int tps65910_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	pmic->desc = kcalloc(pmic->num_regulators,
+	pmic->desc = devm_kzalloc(&pdev->dev, pmic->num_regulators *
 			sizeof(struct regulator_desc), GFP_KERNEL);
 	if (!pmic->desc) {
-		err = -ENOMEM;
-		goto err_out;
+		dev_err(&pdev->dev, "Memory alloc fails for desc\n");
+		return -ENOMEM;
 	}
 
-	pmic->info = kcalloc(pmic->num_regulators,
+	pmic->info = devm_kzalloc(&pdev->dev, pmic->num_regulators *
 			sizeof(struct tps_info *), GFP_KERNEL);
 	if (!pmic->info) {
-		err = -ENOMEM;
-		goto err_free_desc;
+		dev_err(&pdev->dev, "Memory alloc fails for info\n");
+		return -ENOMEM;
 	}
 
-	pmic->rdev = kcalloc(pmic->num_regulators,
+	pmic->rdev = devm_kzalloc(&pdev->dev, pmic->num_regulators *
 			sizeof(struct regulator_dev *), GFP_KERNEL);
 	if (!pmic->rdev) {
-		err = -ENOMEM;
-		goto err_free_info;
+		dev_err(&pdev->dev, "Memory alloc fails for rdev\n");
+		return -ENOMEM;
 	}
 
 	for (i = 0; i < pmic->num_regulators && i < TPS65910_NUM_REGS;
@@ -1286,12 +1286,6 @@ static __devinit int tps65910_probe(struct platform_device *pdev)
 err_unregister_regulator:
 	while (--i >= 0)
 		regulator_unregister(pmic->rdev[i]);
-	kfree(pmic->rdev);
-err_free_info:
-	kfree(pmic->info);
-err_free_desc:
-	kfree(pmic->desc);
-err_out:
 	return err;
 }
 
@@ -1303,9 +1297,6 @@ static int __devexit tps65910_remove(struct platform_device *pdev)
 	for (i = 0; i < pmic->num_regulators; i++)
 		regulator_unregister(pmic->rdev[i]);
 
-	kfree(pmic->rdev);
-	kfree(pmic->info);
-	kfree(pmic->desc);
 	return 0;
 }
 
-- 
1.7.1.1


  parent reply	other threads:[~2012-05-19 14:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-19 14:34 [PATCH 0/5] regulator: tps65910: fixes/cleanups in dt supports Laxman Dewangan
2012-05-19 14:34 ` [PATCH 1/5] regulator: tps65910: use small letter for regulator names Laxman Dewangan
2012-05-19 17:19   ` Mark Brown
2012-05-19 14:34 ` [PATCH 2/5] regulator: tps65910: set of_node for regulator register config Laxman Dewangan
2012-05-19 17:48   ` Mark Brown
2012-05-19 18:19     ` Laxman Dewangan
2012-05-19 18:32       ` Mark Brown
2012-05-19 14:34 ` [PATCH 3/5] regulator: tps65910: use self device for regulator registration Laxman Dewangan
2012-05-19 18:01   ` Mark Brown
2012-05-19 14:34 ` Laxman Dewangan [this message]
2012-05-19 17:41   ` [PATCH 4/5] regulator: tps65910: use devm_* for memory allocation Mark Brown
2012-05-19 14:34 ` [PATCH 5/5] regulator: tps65910: add error message in case of failure Laxman Dewangan
2012-05-19 18:48   ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1337438050-3707-5-git-send-email-ldewangan@nvidia.com \
    --to=ldewangan@nvidia.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome