regulator: Fix _regulator_get_voltage if get_voltage callback is NULL
authorAxel Lin <axel.lin@gmail.com>
Mon, 23 May 2011 12:08:10 +0000 (20:08 +0800)
committerLiam Girdwood <lrg@slimlogic.co.uk>
Fri, 27 May 2011 09:49:30 +0000 (10:49 +0100)
In the case of get_voltage callback is NULL, current implementation in
_regulator_get_voltage will return -EINVAL.

Also returns proper error if ret is negative value.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
drivers/regulator/core.c

index 9493f61..d3e3879 100644 (file)
@@ -1886,12 +1886,14 @@ static int _regulator_get_voltage(struct regulator_dev *rdev)
                if (sel < 0)
                        return sel;
                ret = rdev->desc->ops->list_voltage(rdev, sel);
-       }
-       if (rdev->desc->ops->get_voltage)
+       } else if (rdev->desc->ops->get_voltage) {
                ret = rdev->desc->ops->get_voltage(rdev);
-       else
+       } else {
                return -EINVAL;
+       }
 
+       if (ret < 0)
+               return ret;
        return ret - rdev->constraints->uV_offset;
 }