diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-09-29 20:54:34 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-09-30 13:10:59 -0400 |
commit | ed602534df5d07251c074bafe75feed643c588d1 (patch) | |
tree | 3ce877fdf6f9681e28bca24a09a09122c603fb42 /drivers/regulator/lp872x.c | |
parent | e97bba912eede5e813788bc9ead4a2c29130d377 (diff) |
regulator: lp872x: use devm_regulator_register()
Use devm_regulator_register() to make cleanup paths simpler,
and remove unnecessary remove().
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator/lp872x.c')
-rw-r--r-- | drivers/regulator/lp872x.c | 33 |
1 files changed, 3 insertions, 30 deletions
diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c index 2b84b727a3c4..2e4734ff79fc 100644 --- a/drivers/regulator/lp872x.c +++ b/drivers/regulator/lp872x.c | |||
@@ -785,7 +785,7 @@ static int lp872x_regulator_register(struct lp872x *lp) | |||
785 | struct regulator_desc *desc; | 785 | struct regulator_desc *desc; |
786 | struct regulator_config cfg = { }; | 786 | struct regulator_config cfg = { }; |
787 | struct regulator_dev *rdev; | 787 | struct regulator_dev *rdev; |
788 | int i, ret; | 788 | int i; |
789 | 789 | ||
790 | for (i = 0; i < lp->num_regulators; i++) { | 790 | for (i = 0; i < lp->num_regulators; i++) { |
791 | desc = (lp->chipid == LP8720) ? &lp8720_regulator_desc[i] : | 791 | desc = (lp->chipid == LP8720) ? &lp8720_regulator_desc[i] : |
@@ -796,34 +796,16 @@ static int lp872x_regulator_register(struct lp872x *lp) | |||
796 | cfg.driver_data = lp; | 796 | cfg.driver_data = lp; |
797 | cfg.regmap = lp->regmap; | 797 | cfg.regmap = lp->regmap; |
798 | 798 | ||
799 | rdev = regulator_register(desc, &cfg); | 799 | rdev = devm_regulator_register(lp->dev, desc, &cfg); |
800 | if (IS_ERR(rdev)) { | 800 | if (IS_ERR(rdev)) { |
801 | dev_err(lp->dev, "regulator register err"); | 801 | dev_err(lp->dev, "regulator register err"); |
802 | ret = PTR_ERR(rdev); | 802 | return PTR_ERR(rdev); |
803 | goto err; | ||
804 | } | 803 | } |
805 | 804 | ||
806 | *(lp->regulators + i) = rdev; | 805 | *(lp->regulators + i) = rdev; |
807 | } | 806 | } |
808 | 807 | ||
809 | return 0; | 808 | return 0; |
810 | err: | ||
811 | while (--i >= 0) { | ||
812 | rdev = *(lp->regulators + i); | ||
813 | regulator_unregister(rdev); | ||
814 | } | ||
815 | return ret; | ||
816 | } | ||
817 | |||
818 | static void lp872x_regulator_unregister(struct lp872x *lp) | ||
819 | { | ||
820 | struct regulator_dev *rdev; | ||
821 | int i; | ||
822 | |||
823 | for (i = 0; i < lp->num_regulators; i++) { | ||
824 | rdev = *(lp->regulators + i); | ||
825 | regulator_unregister(rdev); | ||
826 | } | ||
827 | } | 809 | } |
828 | 810 | ||
829 | static const struct regmap_config lp872x_regmap_config = { | 811 | static const struct regmap_config lp872x_regmap_config = { |
@@ -979,14 +961,6 @@ err_dev: | |||
979 | return ret; | 961 | return ret; |
980 | } | 962 | } |
981 | 963 | ||
982 | static int lp872x_remove(struct i2c_client *cl) | ||
983 | { | ||
984 | struct lp872x *lp = i2c_get_clientdata(cl); | ||
985 | |||
986 | lp872x_regulator_unregister(lp); | ||
987 | return 0; | ||
988 | } | ||
989 | |||
990 | static const struct of_device_id lp872x_dt_ids[] = { | 964 | static const struct of_device_id lp872x_dt_ids[] = { |
991 | { .compatible = "ti,lp8720", }, | 965 | { .compatible = "ti,lp8720", }, |
992 | { .compatible = "ti,lp8725", }, | 966 | { .compatible = "ti,lp8725", }, |
@@ -1008,7 +982,6 @@ static struct i2c_driver lp872x_driver = { | |||
1008 | .of_match_table = of_match_ptr(lp872x_dt_ids), | 982 | .of_match_table = of_match_ptr(lp872x_dt_ids), |
1009 | }, | 983 | }, |
1010 | .probe = lp872x_probe, | 984 | .probe = lp872x_probe, |
1011 | .remove = lp872x_remove, | ||
1012 | .id_table = lp872x_ids, | 985 | .id_table = lp872x_ids, |
1013 | }; | 986 | }; |
1014 | 987 | ||