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>
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 81336e2..67d3a61 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -723,13 +723,16 @@
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 @@
{
struct regulator_dev *rdev = regulator->rdev;
int ret;
+ unsigned selector;
mutex_lock(&rdev->mutex);
@@ -1640,7 +1644,13 @@
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);