REGULATOR Handle positive returncode from enable
authorLinus Walleij <linus.walleij@stericsson.com>
Wed, 26 Aug 2009 10:54:04 +0000 (12:54 +0200)
committerLiam Girdwood <lrg@slimlogic.co.uk>
Tue, 22 Sep 2009 12:32:43 +0000 (13:32 +0100)
This makes _regulator_enable() properly handle the case where
a regulator is already on when you try to enable it. Currently
it will erroneously handle positive return values as an error.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
drivers/regulator/core.c

index dbf27bf..744ea1d 100644 (file)
@@ -1236,11 +1236,12 @@ static int _regulator_enable(struct regulator_dev *rdev)
                        } else {
                                return -EINVAL;
                        }
-               } else {
+               } else if (ret < 0) {
                        printk(KERN_ERR "%s: is_enabled() failed for %s: %d\n",
                               __func__, rdev->desc->name, ret);
                        return ret;
                }
+               /* Fallthrough on positive return values - already enabled */
        }
 
        rdev->use_count++;