summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Collins <collinsd@codeaurora.org>2014-09-24 14:30:45 -0700
committerRohit Vaswani <rvaswani@codeaurora.org>2016-03-01 12:22:35 -0800
commite6a67e70d113b9d1ecde427f4dd358e6708d282c (patch)
treea613999f6c2155806eee8f7913504327c210a213
parent16fbe2a1d3a35e5d76966528de0e15eef8ce959e (diff)
regulator: add verbose error messages for invalid voltage requests
Add error messages into the regulator_check_voltage() and regulator_check_consumers() functions which explain exactly what is not correct about given voltage requests. This makes debugging regulator_set_voltage() errors easier. Change-Id: I8b3ec8d6a78c94b436b57bd2228b8bd5c362cecd Signed-off-by: David Collins <collinsd@codeaurora.org>
-rw-r--r--drivers/regulator/core.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index cae41f1d96da..566518eba799 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -224,6 +224,15 @@ static int regulator_check_voltage(struct regulator_dev *rdev,
return -EPERM;
}
+ /* check if requested voltage range actually overlaps the constraints */
+ if (*max_uV < rdev->constraints->min_uV ||
+ *min_uV > rdev->constraints->max_uV) {
+ rdev_err(rdev, "requested voltage range [%d, %d] does not fit "
+ "within constraints: [%d, %d]\n", *min_uV, *max_uV,
+ rdev->constraints->min_uV, rdev->constraints->max_uV);
+ return -EINVAL;
+ }
+
if (*max_uV > rdev->constraints->max_uV)
*max_uV = rdev->constraints->max_uV;
if (*min_uV < rdev->constraints->min_uV)
@@ -245,6 +254,8 @@ static int regulator_check_consumers(struct regulator_dev *rdev,
int *min_uV, int *max_uV)
{
struct regulator *regulator;
+ int init_min_uV = *min_uV;
+ int init_max_uV = *max_uV;
list_for_each_entry(regulator, &rdev->consumer_list, list) {
/*
@@ -254,6 +265,13 @@ static int regulator_check_consumers(struct regulator_dev *rdev,
if (!regulator->min_uV && !regulator->max_uV)
continue;
+ if (init_max_uV < regulator->min_uV
+ || init_min_uV > regulator->max_uV)
+ rdev_err(rdev, "requested voltage range [%d, %d] does "
+ "not fit within previously voted range: "
+ "[%d, %d]\n", init_min_uV, init_max_uV,
+ regulator->min_uV, regulator->max_uV);
+
if (*max_uV > regulator->max_uV)
*max_uV = regulator->max_uV;
if (*min_uV < regulator->min_uV)