diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-09-29 20:53:09 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-09-30 13:10:52 -0400 |
commit | e97bba912eede5e813788bc9ead4a2c29130d377 (patch) | |
tree | 99125dda14a4a0a610c1c0c6d7d80ccf764fcf42 | |
parent | a4a6b9de5c859ff953ce1b854cbfa112718a3f43 (diff) |
regulator: da9063: use devm_regulator_register()
Use devm_regulator_register() to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/regulator/da9063-regulator.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c index 1a7816390773..62b846916e22 100644 --- a/drivers/regulator/da9063-regulator.c +++ b/drivers/regulator/da9063-regulator.c | |||
@@ -847,13 +847,13 @@ static int da9063_regulator_probe(struct platform_device *pdev) | |||
847 | if (da9063_reg_matches) | 847 | if (da9063_reg_matches) |
848 | config.of_node = da9063_reg_matches[id].of_node; | 848 | config.of_node = da9063_reg_matches[id].of_node; |
849 | config.regmap = da9063->regmap; | 849 | config.regmap = da9063->regmap; |
850 | regl->rdev = regulator_register(®l->desc, &config); | 850 | regl->rdev = devm_regulator_register(&pdev->dev, ®l->desc, |
851 | &config); | ||
851 | if (IS_ERR(regl->rdev)) { | 852 | if (IS_ERR(regl->rdev)) { |
852 | dev_err(&pdev->dev, | 853 | dev_err(&pdev->dev, |
853 | "Failed to register %s regulator\n", | 854 | "Failed to register %s regulator\n", |
854 | regl->desc.name); | 855 | regl->desc.name); |
855 | ret = PTR_ERR(regl->rdev); | 856 | return PTR_ERR(regl->rdev); |
856 | goto err; | ||
857 | } | 857 | } |
858 | id++; | 858 | id++; |
859 | n++; | 859 | n++; |
@@ -862,9 +862,8 @@ static int da9063_regulator_probe(struct platform_device *pdev) | |||
862 | /* LDOs overcurrent event support */ | 862 | /* LDOs overcurrent event support */ |
863 | irq = platform_get_irq_byname(pdev, "LDO_LIM"); | 863 | irq = platform_get_irq_byname(pdev, "LDO_LIM"); |
864 | if (irq < 0) { | 864 | if (irq < 0) { |
865 | ret = irq; | ||
866 | dev_err(&pdev->dev, "Failed to get IRQ.\n"); | 865 | dev_err(&pdev->dev, "Failed to get IRQ.\n"); |
867 | goto err; | 866 | return irq; |
868 | } | 867 | } |
869 | 868 | ||
870 | regulators->irq_ldo_lim = regmap_irq_get_virq(da9063->regmap_irq, irq); | 869 | regulators->irq_ldo_lim = regmap_irq_get_virq(da9063->regmap_irq, irq); |
@@ -881,27 +880,15 @@ static int da9063_regulator_probe(struct platform_device *pdev) | |||
881 | } | 880 | } |
882 | 881 | ||
883 | return 0; | 882 | return 0; |
884 | |||
885 | err: | ||
886 | /* Wind back regulators registeration */ | ||
887 | while (--n >= 0) | ||
888 | regulator_unregister(regulators->regulator[n].rdev); | ||
889 | |||
890 | return ret; | ||
891 | } | 883 | } |
892 | 884 | ||
893 | static int da9063_regulator_remove(struct platform_device *pdev) | 885 | static int da9063_regulator_remove(struct platform_device *pdev) |
894 | { | 886 | { |
895 | struct da9063_regulators *regulators = platform_get_drvdata(pdev); | 887 | struct da9063_regulators *regulators = platform_get_drvdata(pdev); |
896 | struct da9063_regulator *regl; | ||
897 | 888 | ||
898 | free_irq(regulators->irq_ldo_lim, regulators); | 889 | free_irq(regulators->irq_ldo_lim, regulators); |
899 | free_irq(regulators->irq_uvov, regulators); | 890 | free_irq(regulators->irq_uvov, regulators); |
900 | 891 | ||
901 | for (regl = ®ulators->regulator[regulators->n_regulators - 1]; | ||
902 | regl >= ®ulators->regulator[0]; regl--) | ||
903 | regulator_unregister(regl->rdev); | ||
904 | |||
905 | return 0; | 892 | return 0; |
906 | } | 893 | } |
907 | 894 | ||