aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/tps6507x-regulator.c
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2013-09-04 07:47:47 -0400
committerMark Brown <broonie@linaro.org>2013-09-16 19:28:43 -0400
commit71b710e705b3b152f0e5682aa179a8c2d2cbb4cd (patch)
tree9a5f067d589831a2b1cb97609aa0f02938f0185e /drivers/regulator/tps6507x-regulator.c
parent9c7c9eae5f7ac57465c0ac6adc8e3ad3afad2544 (diff)
regulator: tps6507x: Use devm_regulator_register
devm_* simplifies the code. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator/tps6507x-regulator.c')
-rw-r--r--drivers/regulator/tps6507x-regulator.c23
1 files changed, 3 insertions, 20 deletions
diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c
index 4117ff52dba1..162a0fae20b3 100644
--- a/drivers/regulator/tps6507x-regulator.c
+++ b/drivers/regulator/tps6507x-regulator.c
@@ -508,13 +508,13 @@ static int tps6507x_pmic_probe(struct platform_device *pdev)
508 config.of_node = tps6507x_reg_matches[i].of_node; 508 config.of_node = tps6507x_reg_matches[i].of_node;
509 } 509 }
510 510
511 rdev = regulator_register(&tps->desc[i], &config); 511 rdev = devm_regulator_register(&pdev->dev, &tps->desc[i],
512 &config);
512 if (IS_ERR(rdev)) { 513 if (IS_ERR(rdev)) {
513 dev_err(tps6507x_dev->dev, 514 dev_err(tps6507x_dev->dev,
514 "failed to register %s regulator\n", 515 "failed to register %s regulator\n",
515 pdev->name); 516 pdev->name);
516 error = PTR_ERR(rdev); 517 return PTR_ERR(rdev);
517 goto fail;
518 } 518 }
519 519
520 /* Save regulator for cleanup */ 520 /* Save regulator for cleanup */
@@ -525,22 +525,6 @@ static int tps6507x_pmic_probe(struct platform_device *pdev)
525 platform_set_drvdata(pdev, tps6507x_dev); 525 platform_set_drvdata(pdev, tps6507x_dev);
526 526
527 return 0; 527 return 0;
528
529fail:
530 while (--i >= 0)
531 regulator_unregister(tps->rdev[i]);
532 return error;
533}
534
535static int tps6507x_pmic_remove(struct platform_device *pdev)
536{
537 struct tps6507x_dev *tps6507x_dev = platform_get_drvdata(pdev);
538 struct tps6507x_pmic *tps = tps6507x_dev->pmic;
539 int i;
540
541 for (i = 0; i < TPS6507X_NUM_REGULATOR; i++)
542 regulator_unregister(tps->rdev[i]);
543 return 0;
544} 528}
545 529
546static struct platform_driver tps6507x_pmic_driver = { 530static struct platform_driver tps6507x_pmic_driver = {
@@ -549,7 +533,6 @@ static struct platform_driver tps6507x_pmic_driver = {
549 .owner = THIS_MODULE, 533 .owner = THIS_MODULE,
550 }, 534 },
551 .probe = tps6507x_pmic_probe, 535 .probe = tps6507x_pmic_probe,
552 .remove = tps6507x_pmic_remove,
553}; 536};
554 537
555static int __init tps6507x_pmic_init(void) 538static int __init tps6507x_pmic_init(void)