Commit 1c9d2d71 authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

regulator: palmas: Fix palmas_probe error handling

Fix below error handling cases:

1. If reading PALMAS_SMPS_CTRL fails, simply returns ret rather than goto
   err_unregister_regulator because we have not call regulator_register().
2. If palmas_ldo_init() fails, we need to call regulator_unregister() for the
   regulator we just successfully registered in this for loop iteration.
Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 2735daeb
...@@ -633,7 +633,7 @@ static __devinit int palmas_probe(struct platform_device *pdev) ...@@ -633,7 +633,7 @@ static __devinit int palmas_probe(struct platform_device *pdev)
ret = palmas_smps_read(palmas, PALMAS_SMPS_CTRL, &reg); ret = palmas_smps_read(palmas, PALMAS_SMPS_CTRL, &reg);
if (ret) if (ret)
goto err_unregister_regulator; return ret;
if (reg & PALMAS_SMPS_CTRL_SMPS12_SMPS123_EN) if (reg & PALMAS_SMPS_CTRL_SMPS12_SMPS123_EN)
pmic->smps123 = 1; pmic->smps123 = 1;
...@@ -783,11 +783,13 @@ static __devinit int palmas_probe(struct platform_device *pdev) ...@@ -783,11 +783,13 @@ static __devinit int palmas_probe(struct platform_device *pdev)
reg_init = pdata->reg_init[id]; reg_init = pdata->reg_init[id];
if (reg_init) { if (reg_init) {
ret = palmas_ldo_init(palmas, id, reg_init); ret = palmas_ldo_init(palmas, id, reg_init);
if (ret) if (ret) {
regulator_unregister(pmic->rdev[id]);
goto err_unregister_regulator; goto err_unregister_regulator;
} }
} }
} }
}
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment