Message ID | 1464862996-3147-2-git-send-email-srinivas.kandagatla@linaro.org |
---|---|
State | New |
Headers | show |
On Thu, Jun 02, 2016 at 11:23:14AM +0100, Srinivas Kandagatla wrote: > Regulator drivers can have linear range which is according to the > regualtor hardware spec, however the board level device tree files > can restrict this range by adding constriants. > These constriants are not considered in the exsiting code, which > gives false supported voltage range to the consumers. ... > For now I have added this support for regulator_list_voltage_linear_range() > If it makes sense we can extend this to other list voltage helpers too. Why are you making this change? The obvious problem here is that drivers should not be looking at constraints - it would be silly to duplicate constraint enforcing code in individual drivers and would lead to inconsistent performance of constraints. This is why we do this in the core, in _regulator_list_voltage(), which means that if this change has any effect there's something else going on that needs to be investigated.
diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c index bcf38fd..379b2b3 100644 --- a/drivers/regulator/helpers.c +++ b/drivers/regulator/helpers.c @@ -16,6 +16,7 @@ #include <linux/delay.h> #include <linux/regmap.h> #include <linux/regulator/consumer.h> +#include <linux/regulator/machine.h> #include <linux/regulator/driver.h> #include <linux/module.h> @@ -374,7 +375,7 @@ int regulator_list_voltage_linear_range(struct regulator_dev *rdev, unsigned int selector) { const struct regulator_linear_range *range; - int i; + int i, v; if (!rdev->desc->n_linear_ranges) { BUG_ON(!rdev->desc->n_linear_ranges); @@ -389,8 +390,13 @@ int regulator_list_voltage_linear_range(struct regulator_dev *rdev, continue; selector -= range->min_sel; + v = range->min_uV + (range->uV_step * selector); - return range->min_uV + (range->uV_step * selector); + if (v < rdev->constraints->min_uV || + v > rdev->constraints->max_uV) + return -EINVAL; + else + return v; } return -EINVAL;
Regulator drivers can have linear range which is according to the regualtor hardware spec, however the board level device tree files can restrict this range by adding constriants. These constriants are not considered in the exsiting code, which gives false supported voltage range to the consumers. Fix this by adding constriants check in the helper function. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> --- For now I have added this support for regulator_list_voltage_linear_range() If it makes sense we can extend this to other list voltage helpers too. drivers/regulator/helpers.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) -- 2.8.2 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html