regulator: core: Use list_voltage() to read single voltage regulators
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 9 Aug 2012 15:42:19 +0000 (16:42 +0100)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 9 Aug 2012 18:48:27 +0000 (19:48 +0100)
If the regulator doesn't supply a way of reading back the voltage but does
provide a list_voltage() operation then use that with a selector of zero
to read the voltage.  Regulators doing this means that we have the list
operation there for consumers that want to configure themselves.

Reported-by: Stephen Warren <swarren@wwwdotorg.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/regulator/core.c

index 157def15ed783d1f12c692e57a9e2d30bdf8976a..ff8f544473058bd229386fe06240e1a3124ef7fa 100644 (file)
@@ -2395,6 +2395,8 @@ static int _regulator_get_voltage(struct regulator_dev *rdev)
                ret = rdev->desc->ops->list_voltage(rdev, sel);
        } else if (rdev->desc->ops->get_voltage) {
                ret = rdev->desc->ops->get_voltage(rdev);
+       } else if (rdev->desc->ops->list_voltage) {
+               ret = rdev->desc->ops->list_voltage(rdev, 0);
        } else {
                return -EINVAL;
        }