]> git.neil.brown.name Git - gta04.git/commitdiff
regulator: palmas: Fix palmas_probe error handling
authorAxel Lin <axel.lin@gmail.com>
Wed, 18 Jul 2012 04:33:20 +0000 (12:33 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 7 Aug 2012 17:10:26 +0000 (18:10 +0100)
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>
drivers/regulator/palmas-regulator.c

index de68347cbc69c8de4c4e2b39e4f618bab4d5c8b1..46c7e88f8381910004a4e46b0a3a722a1bcd7f28 100644 (file)
@@ -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;
@@ -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;
+                               }
                        }
                }
        }