From: Ashish Jangam <ashish.jangam@kpitcummins.com>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: <linaro-dev@lists.linaro.org>, <lrg@slimlogic.co.uk>,
<linux-kernel@vger.kernel.org>, Dajun <dajun.chen@diasemi.com>,
<paul.liu@linaro.org>, <sameo@linux.intel.com>
Subject: [Patch] Regulator: Replace kzalloc with devm_kzalloc and if-else with a switch-case for da9052-regulator
Date: Thu, 15 Dec 2011 18:59:53 +0530 [thread overview]
Message-ID: <1323955793.32031.88.camel@dhruva> (raw)
Reported-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: David Dajun Chen <dchen@diasemi.com>
Signed-off-by: Ashish Jangam <ashish.jangam@kpitcummins.com>
---
drivers/regulator/da9052-regulator.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c
index 9fff281..37a20c1 100755
--- a/drivers/regulator/da9052-regulator.c
+++ b/drivers/regulator/da9052-regulator.c
@@ -505,18 +505,23 @@ static inline struct da9052_regulator_info *find_regulator_info(u8 chip_id,
struct da9052_regulator_info *info;
int i;
- if (chip_id == DA9052) {
+ switch (chip_id) {
+ case DA9052:
for (i = 0; i < ARRAY_SIZE(da9052_regulator_info); i++) {
info = &da9052_regulator_info[i];
if (info->reg_desc.id == id)
return info;
}
- } else {
+ break;
+ case DA9053_AA:
+ case DA9053_BA:
+ case DA9053_BB:
for (i = 0; i < ARRAY_SIZE(da9053_regulator_info); i++) {
info = &da9053_regulator_info[i];
if (info->reg_desc.id == id)
return info;
}
+ break;
}
return NULL;
@@ -529,7 +534,8 @@ static int __devinit da9052_regulator_probe(struct platform_device *pdev)
struct da9052_pdata *pdata;
int ret;
- regulator = kzalloc(sizeof(struct da9052_regulator), GFP_KERNEL);
+ regulator = devm_kzalloc(&pdev->dev, sizeof(struct da9052_regulator),
+ GFP_KERNEL);
if (!regulator)
return -ENOMEM;
@@ -559,7 +565,7 @@ static int __devinit da9052_regulator_probe(struct platform_device *pdev)
return 0;
err:
- kfree(regulator);
+ devm_kfree(&pdev->dev, regulator);
return ret;
}
@@ -568,7 +574,7 @@ static int __devexit da9052_regulator_remove(struct platform_device *pdev)
struct da9052_regulator *regulator = platform_get_drvdata(pdev);
regulator_unregister(regulator->rdev);
- kfree(regulator);
+ devm_kfree(&pdev->dev, regulator);
return 0;
}
next reply other threads:[~2011-12-15 13:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-15 13:29 Ashish Jangam [this message]
2011-12-17 9:26 ` [Patch] Regulator: Replace kzalloc with devm_kzalloc and if-else with a switch-case for da9052-regulator 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=1323955793.32031.88.camel@dhruva \
--to=ashish.jangam@kpitcummins.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=dajun.chen@diasemi.com \
--cc=linaro-dev@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@slimlogic.co.uk \
--cc=paul.liu@linaro.org \
--cc=sameo@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.