aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/da9052-regulator.c
diff options
context:
space:
mode:
authorAshish Jangam <ashish.jangam@kpitcummins.com>2011-12-15 08:29:53 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-12-17 04:25:47 -0500
commit984b5a6ba550f41edda86d0b6deba2b5187f5e44 (patch)
tree1aba0acdf6860c73a86fa9f521767224ae380e6e /drivers/regulator/da9052-regulator.c
parent47aed92c7740c33f3acbd9dbdefb5ec6f9effdc0 (diff)
regulator: Replace kzalloc with devm_kzalloc and if-else with a switch-case for da9052-regulator
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> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/da9052-regulator.c')
-rw-r--r--drivers/regulator/da9052-regulator.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c
index bdb43757d7c7..f2840b522cde 100644
--- 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,
505 struct da9052_regulator_info *info; 505 struct da9052_regulator_info *info;
506 int i; 506 int i;
507 507
508 if (chip_id == DA9052) { 508 switch (chip_id) {
509 case DA9052:
509 for (i = 0; i < ARRAY_SIZE(da9052_regulator_info); i++) { 510 for (i = 0; i < ARRAY_SIZE(da9052_regulator_info); i++) {
510 info = &da9052_regulator_info[i]; 511 info = &da9052_regulator_info[i];
511 if (info->reg_desc.id == id) 512 if (info->reg_desc.id == id)
512 return info; 513 return info;
513 } 514 }
514 } else { 515 break;
516 case DA9053_AA:
517 case DA9053_BA:
518 case DA9053_BB:
515 for (i = 0; i < ARRAY_SIZE(da9053_regulator_info); i++) { 519 for (i = 0; i < ARRAY_SIZE(da9053_regulator_info); i++) {
516 info = &da9053_regulator_info[i]; 520 info = &da9053_regulator_info[i];
517 if (info->reg_desc.id == id) 521 if (info->reg_desc.id == id)
518 return info; 522 return info;
519 } 523 }
524 break;
520 } 525 }
521 526
522 return NULL; 527 return NULL;
@@ -529,7 +534,8 @@ static int __devinit da9052_regulator_probe(struct platform_device *pdev)
529 struct da9052_pdata *pdata; 534 struct da9052_pdata *pdata;
530 int ret; 535 int ret;
531 536
532 regulator = kzalloc(sizeof(struct da9052_regulator), GFP_KERNEL); 537 regulator = devm_kzalloc(&pdev->dev, sizeof(struct da9052_regulator),
538 GFP_KERNEL);
533 if (!regulator) 539 if (!regulator)
534 return -ENOMEM; 540 return -ENOMEM;
535 541
@@ -559,7 +565,7 @@ static int __devinit da9052_regulator_probe(struct platform_device *pdev)
559 565
560 return 0; 566 return 0;
561err: 567err:
562 kfree(regulator); 568 devm_kfree(&pdev->dev, regulator);
563 return ret; 569 return ret;
564} 570}
565 571
@@ -568,7 +574,7 @@ static int __devexit da9052_regulator_remove(struct platform_device *pdev)
568 struct da9052_regulator *regulator = platform_get_drvdata(pdev); 574 struct da9052_regulator *regulator = platform_get_drvdata(pdev);
569 575
570 regulator_unregister(regulator->rdev); 576 regulator_unregister(regulator->rdev);
571 kfree(regulator); 577 devm_kfree(&pdev->dev, regulator);
572 578
573 return 0; 579 return 0;
574} 580}