diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2013-09-04 02:30:59 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-09-16 19:28:42 -0400 |
commit | 8e568635afcce245d771c2fc527f3902b6d2e723 (patch) | |
tree | 7ec0cfd606d8a54fddc9fc55f7e184a0cf75fca6 | |
parent | 0ab6e8ca54d22f986a488bbc493e01f1394a3b2b (diff) |
regulator: mc13783: Use devm_regulator_register
devm_* simplifies the code.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Acked-by: Marek Vasut <marex@denx.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/regulator/mc13783-regulator.c | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/drivers/regulator/mc13783-regulator.c b/drivers/regulator/mc13783-regulator.c index 5ff99d2703db..f036b26d4cfc 100644 --- a/drivers/regulator/mc13783-regulator.c +++ b/drivers/regulator/mc13783-regulator.c | |||
@@ -400,7 +400,7 @@ static int mc13783_regulator_probe(struct platform_device *pdev) | |||
400 | dev_get_platdata(&pdev->dev); | 400 | dev_get_platdata(&pdev->dev); |
401 | struct mc13xxx_regulator_init_data *mc13xxx_data; | 401 | struct mc13xxx_regulator_init_data *mc13xxx_data; |
402 | struct regulator_config config = { }; | 402 | struct regulator_config config = { }; |
403 | int i, ret, num_regulators; | 403 | int i, num_regulators; |
404 | 404 | ||
405 | num_regulators = mc13xxx_get_num_regulators_dt(pdev); | 405 | num_regulators = mc13xxx_get_num_regulators_dt(pdev); |
406 | 406 | ||
@@ -444,32 +444,16 @@ static int mc13783_regulator_probe(struct platform_device *pdev) | |||
444 | config.driver_data = priv; | 444 | config.driver_data = priv; |
445 | config.of_node = node; | 445 | config.of_node = node; |
446 | 446 | ||
447 | priv->regulators[i] = regulator_register(desc, &config); | 447 | priv->regulators[i] = devm_regulator_register(&pdev->dev, desc, |
448 | &config); | ||
448 | if (IS_ERR(priv->regulators[i])) { | 449 | if (IS_ERR(priv->regulators[i])) { |
449 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 450 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
450 | mc13783_regulators[i].desc.name); | 451 | mc13783_regulators[i].desc.name); |
451 | ret = PTR_ERR(priv->regulators[i]); | 452 | return PTR_ERR(priv->regulators[i]); |
452 | goto err; | ||
453 | } | 453 | } |
454 | } | 454 | } |
455 | 455 | ||
456 | return 0; | 456 | return 0; |
457 | err: | ||
458 | while (--i >= 0) | ||
459 | regulator_unregister(priv->regulators[i]); | ||
460 | |||
461 | return ret; | ||
462 | } | ||
463 | |||
464 | static int mc13783_regulator_remove(struct platform_device *pdev) | ||
465 | { | ||
466 | struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev); | ||
467 | int i; | ||
468 | |||
469 | for (i = 0; i < priv->num_regulators; i++) | ||
470 | regulator_unregister(priv->regulators[i]); | ||
471 | |||
472 | return 0; | ||
473 | } | 457 | } |
474 | 458 | ||
475 | static struct platform_driver mc13783_regulator_driver = { | 459 | static struct platform_driver mc13783_regulator_driver = { |
@@ -477,7 +461,6 @@ static struct platform_driver mc13783_regulator_driver = { | |||
477 | .name = "mc13783-regulator", | 461 | .name = "mc13783-regulator", |
478 | .owner = THIS_MODULE, | 462 | .owner = THIS_MODULE, |
479 | }, | 463 | }, |
480 | .remove = mc13783_regulator_remove, | ||
481 | .probe = mc13783_regulator_probe, | 464 | .probe = mc13783_regulator_probe, |
482 | }; | 465 | }; |
483 | 466 | ||