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/mc13783-regulator.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'drivers/regulator/mc13783-regulator.c') diff --git a/drivers/regulator/mc13783-regulator.c b/drivers/regulator/mc13783-regulator.c index ecd99f59dba8..47ea99949798 100644 --- a/drivers/regulator/mc13783-regulator.c +++ b/drivers/regulator/mc13783-regulator.c @@ -373,7 +373,8 @@ static int mc13783_get_best_voltage_index(struct regulator_dev *rdev, } static int mc13783_regulator_set_voltage(struct regulator_dev *rdev, - int min_uV, int max_uV) + int min_uV, int max_uV, + unsigned *selector) { struct mc13783_regulator_priv *priv = rdev_get_drvdata(rdev); int value, id = rdev_get_id(rdev); @@ -388,6 +389,8 @@ static int mc13783_regulator_set_voltage(struct regulator_dev *rdev, if (value < 0) return value; + *selector = value; + mc13783_lock(priv->mc13783); ret = mc13783_reg_rmw(priv->mc13783, mc13783_regulators[id].vsel_reg, mc13783_regulators[id].vsel_mask, @@ -433,13 +436,16 @@ static struct regulator_ops mc13783_regulator_ops = { }; static int mc13783_fixed_regulator_set_voltage(struct regulator_dev *rdev, - int min_uV, int max_uV) + int min_uV, int max_uV, + unsigned int *selector) { int id = rdev_get_id(rdev); dev_dbg(rdev_get_dev(rdev), "%s id: %d min_uV: %d max_uV: %d\n", __func__, id, min_uV, max_uV); + *selector = 0; + if (min_uV >= mc13783_regulators[id].voltages[0] && max_uV <= mc13783_regulators[id].voltages[0]) return 0; -- cgit v1.2.1