summaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorMatti Vaittinen <matti.vaittinen@fi.rohmeurope.com>2018-08-22 11:53:27 +0200
committerMark Brown <broonie@kernel.org>2018-08-28 21:30:24 +0200
commite7d80b6b848b4b5f83d3fbee9fd042d036ede9c6 (patch)
tree4bc8be6103c7cc943828e977ec68f7a97cadd96c /drivers/regulator
parentregulator: bd71837: Remove duplicate assignment for n_voltages of LDO2 (diff)
downloadlinux-e7d80b6b848b4b5f83d3fbee9fd042d036ede9c6.tar.xz
linux-e7d80b6b848b4b5f83d3fbee9fd042d036ede9c6.zip
regulator: regmap helpers - support overlapping linear ranges
Don't give up voltage mapping if first range with suitable min/max uV does not provide the wanted voltage. Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/helpers.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c
index 2ae7c3ac5940..ef09021dc46e 100644
--- a/drivers/regulator/helpers.c
+++ b/drivers/regulator/helpers.c
@@ -321,17 +321,18 @@ int regulator_map_voltage_linear_range(struct regulator_dev *rdev,
ret += range->min_sel;
- break;
+ /*
+ * Map back into a voltage to verify we're still in bounds.
+ * If we are not, then continue checking rest of the ranges.
+ */
+ voltage = rdev->desc->ops->list_voltage(rdev, ret);
+ if (voltage >= min_uV && voltage <= max_uV)
+ break;
}
if (i == rdev->desc->n_linear_ranges)
return -EINVAL;
- /* Map back into a voltage to verify we're still in bounds */
- voltage = rdev->desc->ops->list_voltage(rdev, ret);
- if (voltage < min_uV || voltage > max_uV)
- return -EINVAL;
-
return ret;
}
EXPORT_SYMBOL_GPL(regulator_map_voltage_linear_range);