aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2013-09-04 01:37:59 -0400
committerMark Brown <broonie@linaro.org>2013-09-16 19:28:41 -0400
commit5ecdf140f21c50c08be34a83b44f28722813366c (patch)
tree7a8b4d38ca51cb137813ea52c771b86a4a0c7a3f
parentdcfb6b56f18b5d9eff9b784d4e5b4a085f149de2 (diff)
regulator: max8907-regulator: 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>
-rw-r--r--drivers/regulator/max8907-regulator.c23
1 files changed, 3 insertions, 20 deletions
diff --git a/drivers/regulator/max8907-regulator.c b/drivers/regulator/max8907-regulator.c
index 4568c15fa78d..0c5fe6c6ac26 100644
--- a/drivers/regulator/max8907-regulator.c
+++ b/drivers/regulator/max8907-regulator.c
@@ -350,33 +350,17 @@ static int max8907_regulator_probe(struct platform_device *pdev)
350 pmic->desc[i].ops = &max8907_out5v_hwctl_ops; 350 pmic->desc[i].ops = &max8907_out5v_hwctl_ops;
351 } 351 }
352 352
353 pmic->rdev[i] = regulator_register(&pmic->desc[i], &config); 353 pmic->rdev[i] = devm_regulator_register(&pdev->dev,
354 &pmic->desc[i], &config);
354 if (IS_ERR(pmic->rdev[i])) { 355 if (IS_ERR(pmic->rdev[i])) {
355 dev_err(&pdev->dev, 356 dev_err(&pdev->dev,
356 "failed to register %s regulator\n", 357 "failed to register %s regulator\n",
357 pmic->desc[i].name); 358 pmic->desc[i].name);
358 ret = PTR_ERR(pmic->rdev[i]); 359 return PTR_ERR(pmic->rdev[i]);
359 goto err_unregister_regulator;
360 } 360 }
361 } 361 }
362 362
363 return 0; 363 return 0;
364
365err_unregister_regulator:
366 while (--i >= 0)
367 regulator_unregister(pmic->rdev[i]);
368 return ret;
369}
370
371static int max8907_regulator_remove(struct platform_device *pdev)
372{
373 struct max8907_regulator *pmic = platform_get_drvdata(pdev);
374 int i;
375
376 for (i = 0; i < MAX8907_NUM_REGULATORS; i++)
377 regulator_unregister(pmic->rdev[i]);
378
379 return 0;
380} 364}
381 365
382static struct platform_driver max8907_regulator_driver = { 366static struct platform_driver max8907_regulator_driver = {
@@ -385,7 +369,6 @@ static struct platform_driver max8907_regulator_driver = {
385 .owner = THIS_MODULE, 369 .owner = THIS_MODULE,
386 }, 370 },
387 .probe = max8907_regulator_probe, 371 .probe = max8907_regulator_probe,
388 .remove = max8907_regulator_remove,
389}; 372};
390 373
391static int __init max8907_regulator_init(void) 374static int __init max8907_regulator_init(void)