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

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>

authored by

Jingoo Han and committed by
Mark Brown
e97bba91 a4a6b9de

+4 -17
+4 -17
drivers/regulator/da9063-regulator.c
··· 847 847 if (da9063_reg_matches) 848 848 config.of_node = da9063_reg_matches[id].of_node; 849 849 config.regmap = da9063->regmap; 850 - regl->rdev = regulator_register(&regl->desc, &config); 850 + regl->rdev = devm_regulator_register(&pdev->dev, &regl->desc, 851 + &config); 851 852 if (IS_ERR(regl->rdev)) { 852 853 dev_err(&pdev->dev, 853 854 "Failed to register %s regulator\n", 854 855 regl->desc.name); 855 - ret = PTR_ERR(regl->rdev); 856 - goto err; 856 + return PTR_ERR(regl->rdev); 857 857 } 858 858 id++; 859 859 n++; ··· 862 862 /* LDOs overcurrent event support */ 863 863 irq = platform_get_irq_byname(pdev, "LDO_LIM"); 864 864 if (irq < 0) { 865 - ret = irq; 866 865 dev_err(&pdev->dev, "Failed to get IRQ.\n"); 867 - goto err; 866 + return irq; 868 867 } 869 868 870 869 regulators->irq_ldo_lim = regmap_irq_get_virq(da9063->regmap_irq, irq); ··· 880 881 } 881 882 882 883 return 0; 883 - 884 - err: 885 - /* Wind back regulators registeration */ 886 - while (--n >= 0) 887 - regulator_unregister(regulators->regulator[n].rdev); 888 - 889 - return ret; 890 884 } 891 885 892 886 static int da9063_regulator_remove(struct platform_device *pdev) 893 887 { 894 888 struct da9063_regulators *regulators = platform_get_drvdata(pdev); 895 - struct da9063_regulator *regl; 896 889 897 890 free_irq(regulators->irq_ldo_lim, regulators); 898 891 free_irq(regulators->irq_uvov, regulators); 899 - 900 - for (regl = &regulators->regulator[regulators->n_regulators - 1]; 901 - regl >= &regulators->regulator[0]; regl--) 902 - regulator_unregister(regl->rdev); 903 892 904 893 return 0; 905 894 }