Skip to content

Commit

Permalink
regulator: palmas: Fix palmas_probe error handling
Browse files Browse the repository at this point in the history
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: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Axel Lin authored and Mark Brown committed Aug 7, 2012
1 parent 2735dae commit 1c9d2d7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/regulator/palmas-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ static __devinit int palmas_probe(struct platform_device *pdev)

ret = palmas_smps_read(palmas, PALMAS_SMPS_CTRL, &reg);
if (ret)
goto err_unregister_regulator;
return ret;

if (reg & PALMAS_SMPS_CTRL_SMPS12_SMPS123_EN)
pmic->smps123 = 1;
Expand Down Expand Up @@ -783,8 +783,10 @@ static __devinit int palmas_probe(struct platform_device *pdev)
reg_init = pdata->reg_init[id];
if (reg_init) {
ret = palmas_ldo_init(palmas, id, reg_init);
if (ret)
if (ret) {
regulator_unregister(pmic->rdev[id]);
goto err_unregister_regulator;
}
}
}
}
Expand Down

0 comments on commit 1c9d2d7

Please sign in to comment.