diff options
Diffstat (limited to 'drivers/regulator/helpers.c')
-rw-r--r-- | drivers/regulator/helpers.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c index d2b9fc359318..5686a1335bd3 100644 --- a/drivers/regulator/helpers.c +++ b/drivers/regulator/helpers.c @@ -443,17 +443,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); |