diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-11-10 14:38:29 +0000 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2011-01-12 14:32:59 +0000 |
commit | 3a93f2a9f4d8f73d74c0e552feb68a10f778a219 (patch) | |
tree | 8a9f503f2f061ad3fe9712b0986b0da346f4c8d2 /drivers/regulator/core.c | |
parent | 63cee946148821bca42be10130b061c2d0f5af7e (diff) |
regulator: Report actual configured voltage to set_voltage()
Change the interface used by set_voltage() to report the selected value
to the regulator core in terms of a selector used by list_voltage().
This allows the regulator core to know the voltage that was chosen
without having to do an explict get_voltage(), which would be much more
expensive as it will generally access hardware.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r-- | drivers/regulator/core.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 81336e23848..67d3a61f378 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -723,13 +723,16 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, struct regulator_ops *ops = rdev->desc->ops; const char *name = rdev_get_name(rdev); int ret; + unsigned selector; /* do we need to apply the constraint voltage */ if (rdev->constraints->apply_uV && rdev->constraints->min_uV == rdev->constraints->max_uV && ops->set_voltage) { ret = ops->set_voltage(rdev, - rdev->constraints->min_uV, rdev->constraints->max_uV); + rdev->constraints->min_uV, + rdev->constraints->max_uV, + &selector); if (ret < 0) { printk(KERN_ERR "%s: failed to apply %duV constraint to %s\n", __func__, @@ -1625,6 +1628,7 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV) { struct regulator_dev *rdev = regulator->rdev; int ret; + unsigned selector; mutex_lock(&rdev->mutex); @@ -1640,7 +1644,13 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV) goto out; regulator->min_uV = min_uV; regulator->max_uV = max_uV; - ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV); + + ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV, &selector); + + if (rdev->desc->ops->list_voltage) + selector = rdev->desc->ops->list_voltage(rdev, selector); + else + selector = -1; out: _notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE, NULL); |