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

regulator: ab8500: use devm_regulator_register()

Use devm_regulator_register() to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>

authored by

Jingoo Han and committed by
Mark Brown
baafdc1d 34c040ce

+4 -20
+4 -20
drivers/regulator/ab8500.c
··· 3005 3005 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); 3006 3006 struct ab8500_regulator_info *info = NULL; 3007 3007 struct regulator_config config = { }; 3008 - int err; 3009 3008 3010 3009 /* assign per-regulator data */ 3011 3010 info = &abx500_regulator.info[id]; ··· 3026 3027 } 3027 3028 3028 3029 /* register regulator with framework */ 3029 - info->regulator = regulator_register(&info->desc, &config); 3030 + info->regulator = devm_regulator_register(&pdev->dev, &info->desc, 3031 + &config); 3030 3032 if (IS_ERR(info->regulator)) { 3031 - err = PTR_ERR(info->regulator); 3032 3033 dev_err(&pdev->dev, "failed to register regulator %s\n", 3033 3034 info->desc.name); 3034 - /* when we fail, un-register all earlier regulators */ 3035 - while (--id >= 0) { 3036 - info = &abx500_regulator.info[id]; 3037 - regulator_unregister(info->regulator); 3038 - } 3039 - return err; 3035 + return PTR_ERR(info->regulator); 3040 3036 } 3041 3037 3042 3038 return 0; ··· 3080 3086 3081 3087 static int ab8500_regulator_remove(struct platform_device *pdev) 3082 3088 { 3083 - int i, err; 3084 - 3085 - for (i = 0; i < abx500_regulator.info_size; i++) { 3086 - struct ab8500_regulator_info *info = NULL; 3087 - info = &abx500_regulator.info[i]; 3088 - 3089 - dev_vdbg(rdev_get_dev(info->regulator), 3090 - "%s-remove\n", info->desc.name); 3091 - 3092 - regulator_unregister(info->regulator); 3093 - } 3089 + int err; 3094 3090 3095 3091 /* remove regulator debug */ 3096 3092 err = ab8500_regulator_debug_exit(pdev);