diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-11-10 09:38:29 -0500 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2011-01-12 09:32:59 -0500 |
commit | 3a93f2a9f4d8f73d74c0e552feb68a10f778a219 (patch) | |
tree | 8a9f503f2f061ad3fe9712b0986b0da346f4c8d2 /drivers/regulator/max8998.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/max8998.c')
-rw-r--r-- | drivers/regulator/max8998.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index 5c20756db607..cb28cf8b9397 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c | |||
@@ -304,7 +304,7 @@ static int max8998_get_voltage(struct regulator_dev *rdev) | |||
304 | } | 304 | } |
305 | 305 | ||
306 | static int max8998_set_voltage_ldo(struct regulator_dev *rdev, | 306 | static int max8998_set_voltage_ldo(struct regulator_dev *rdev, |
307 | int min_uV, int max_uV) | 307 | int min_uV, int max_uV, unsigned *selector) |
308 | { | 308 | { |
309 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); | 309 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); |
310 | struct i2c_client *i2c = max8998->iodev->i2c; | 310 | struct i2c_client *i2c = max8998->iodev->i2c; |
@@ -331,6 +331,8 @@ static int max8998_set_voltage_ldo(struct regulator_dev *rdev, | |||
331 | if (desc->min + desc->step*i > max_vol) | 331 | if (desc->min + desc->step*i > max_vol) |
332 | return -EINVAL; | 332 | return -EINVAL; |
333 | 333 | ||
334 | *selector = i; | ||
335 | |||
334 | ret = max8998_get_voltage_register(rdev, ®, &shift, &mask); | 336 | ret = max8998_get_voltage_register(rdev, ®, &shift, &mask); |
335 | if (ret) | 337 | if (ret) |
336 | return ret; | 338 | return ret; |
@@ -352,7 +354,7 @@ static inline void buck2_gpio_set(int gpio, int v) | |||
352 | } | 354 | } |
353 | 355 | ||
354 | static int max8998_set_voltage_buck(struct regulator_dev *rdev, | 356 | static int max8998_set_voltage_buck(struct regulator_dev *rdev, |
355 | int min_uV, int max_uV) | 357 | int min_uV, int max_uV, int *selector) |
356 | { | 358 | { |
357 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); | 359 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); |
358 | struct max8998_platform_data *pdata = | 360 | struct max8998_platform_data *pdata = |
@@ -384,6 +386,8 @@ static int max8998_set_voltage_buck(struct regulator_dev *rdev, | |||
384 | if (desc->min + desc->step*i > max_vol) | 386 | if (desc->min + desc->step*i > max_vol) |
385 | return -EINVAL; | 387 | return -EINVAL; |
386 | 388 | ||
389 | *selector = i; | ||
390 | |||
387 | ret = max8998_get_voltage_register(rdev, ®, &shift, &mask); | 391 | ret = max8998_get_voltage_register(rdev, ®, &shift, &mask); |
388 | if (ret) | 392 | if (ret) |
389 | return ret; | 393 | return ret; |