]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
regulator: regmap helpers - support overlapping linear ranges
authorMatti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Wed, 22 Aug 2018 09:53:27 +0000 (12:53 +0300)
committerMark Brown <broonie@kernel.org>
Tue, 28 Aug 2018 19:30:24 +0000 (20:30 +0100)
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>
drivers/regulator/helpers.c

index 2ae7c3ac5940ec29b52870f4619905e7040aaf20..ef09021dc46e50f134fcb76d3d1d9e6dd22064c7 100644 (file)
@@ -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);