[RFC PATCH v1 1/3] regulator: helpers: consider constriants in list_voltage_linear_range

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---

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(-)

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;
--
2.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux