Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jingoo Han and committed by
Mark Brown
ed602534 e97bba91

+3 -30
+3 -30
drivers/regulator/lp872x.c
··· 785 785 struct regulator_desc *desc; 786 786 struct regulator_config cfg = { }; 787 787 struct regulator_dev *rdev; 788 - int i, ret; 788 + int i; 789 789 790 790 for (i = 0; i < lp->num_regulators; i++) { 791 791 desc = (lp->chipid == LP8720) ? &lp8720_regulator_desc[i] : ··· 796 796 cfg.driver_data = lp; 797 797 cfg.regmap = lp->regmap; 798 798 799 - rdev = regulator_register(desc, &cfg); 799 + rdev = devm_regulator_register(lp->dev, desc, &cfg); 800 800 if (IS_ERR(rdev)) { 801 801 dev_err(lp->dev, "regulator register err"); 802 - ret = PTR_ERR(rdev); 803 - goto err; 802 + return PTR_ERR(rdev); 804 803 } 805 804 806 805 *(lp->regulators + i) = rdev; 807 806 } 808 807 809 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 811 static const struct regmap_config lp872x_regmap_config = { ··· 961 979 return ret; 962 980 } 963 981 964 - static int lp872x_remove(struct i2c_client *cl) 965 - { 966 - struct lp872x *lp = i2c_get_clientdata(cl); 967 - 968 - lp872x_regulator_unregister(lp); 969 - return 0; 970 - } 971 - 972 982 static const struct of_device_id lp872x_dt_ids[] = { 973 983 { .compatible = "ti,lp8720", }, 974 984 { .compatible = "ti,lp8725", }, ··· 982 1008 .of_match_table = of_match_ptr(lp872x_dt_ids), 983 1009 }, 984 1010 .probe = lp872x_probe, 985 - .remove = lp872x_remove, 986 1011 .id_table = lp872x_ids, 987 1012 }; 988 1013