summaryrefslogtreecommitdiffstats
path: root/drivers/regulator/core.c
diff options
context:
space:
mode:
authorMark Brown2012-07-02 16:00:18 +0200
committerMark Brown2012-07-03 21:27:58 +0200
commitc5f3939b8fe0c358d35397982e5afdef112afc81 (patch)
tree94bff02c8f75418d0b68795bcf3c1ae9c2a51a9c /drivers/regulator/core.c
parentregulator: add missing defintion regulator_is_supported_voltage (diff)
downloadkernel-qcow2-linux-c5f3939b8fe0c358d35397982e5afdef112afc81.tar.gz
kernel-qcow2-linux-c5f3939b8fe0c358d35397982e5afdef112afc81.tar.xz
kernel-qcow2-linux-c5f3939b8fe0c358d35397982e5afdef112afc81.zip
regulator: core: Support fixed voltages in regulator_is_supported_voltage()
Currently regulator_is_supported_voltage() works by enumerating the set of voltages which can be set by the regulator but the checks we're doing to impose constraints mean that if we can't vary the voltage we'll not report any voltages as supported even though the regulator is actually set at that voltage. We could fix the voltage listing but this would mean that list_voltage() could end up going to the hardware to get the current voltage which isn't expected (it's supposed to be very cheap) so instead special case things when we can't change the voltage and compare the requested range against the current voltage. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r--drivers/regulator/core.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index d886ee265e47..a80886626230 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1890,8 +1890,18 @@ EXPORT_SYMBOL_GPL(regulator_list_voltage);
int regulator_is_supported_voltage(struct regulator *regulator,
int min_uV, int max_uV)
{
+ struct regulator_dev *rdev = regulator->rdev;
int i, voltages, ret;
+ /* If we can't change voltage check the current voltage */
+ if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) {
+ ret = regulator_get_voltage(regulator);
+ if (ret >= 0)
+ return (min_uV >= ret && ret <= max_uV);
+ else
+ return ret;
+ }
+
ret = regulator_count_voltages(regulator);
if (ret < 0)
return ret;