From 3a93f2a9f4d8f73d74c0e552feb68a10f778a219 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 10 Nov 2010 14:38:29 +0000 Subject: 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 Signed-off-by: Liam Girdwood --- drivers/regulator/core.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'drivers/regulator/core.c') 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); -- cgit v1.2.3