All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch] Regulator: Replace kzalloc with devm_kzalloc and if-else with a switch-case for da9052-regulator
@ 2011-12-15 13:29 Ashish Jangam
  2011-12-17  9:26 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Ashish Jangam @ 2011-12-15 13:29 UTC (permalink / raw)
  To: Mark Brown; +Cc: linaro-dev, lrg, linux-kernel, Dajun, paul.liu, sameo

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;
 }



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Patch] Regulator: Replace kzalloc with devm_kzalloc and if-else with a switch-case for da9052-regulator
  2011-12-15 13:29 [Patch] Regulator: Replace kzalloc with devm_kzalloc and if-else with a switch-case for da9052-regulator Ashish Jangam
@ 2011-12-17  9:26 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2011-12-17  9:26 UTC (permalink / raw)
  To: Ashish Jangam; +Cc: linaro-dev, lrg, linux-kernel, Dajun, paul.liu, sameo

On Thu, Dec 15, 2011 at 06:59:53PM +0530, Ashish Jangam wrote:
> 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>

Applied, but this really should have been sent as two separate patches
as it's two unrelated changes which don't overlap with each other.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-12-17  9:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-15 13:29 [Patch] Regulator: Replace kzalloc with devm_kzalloc and if-else with a switch-case for da9052-regulator Ashish Jangam
2011-12-17  9:26 ` Mark Brown

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.