summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRabin Vincent <rabin.vincent@stericsson.com>2011-05-06 16:13:46 +0530
committerHenrik Aberg <henrik.aberg@stericsson.com>2011-05-18 09:40:15 +0200
commit33e374b8e696c6d465a8243838f5ff0aca54ec4b (patch)
tree4b06eb1c628cdb7c76f9244fe2ab9439f31047e5
parent33b384989258f6bcd41da2e22431fe105b9d51dc (diff)
regulator/ab5500: correctly handle holes in voltage list
The handling of get_voltage() for regulators where there are holes in the voltage list is buggy. Fix it. ST-Ericsson Linux next: - ST-Ericsson ID: WP257121 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I1b0db7943ccc057a0ea13208b934e54f1fc392cd Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/22506 Tested-by: Rabin VINCENT <rabin.vincent@stericsson.com> Reviewed-by: QATEST Reviewed-by: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
-rw-r--r--drivers/regulator/ab5500.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/regulator/ab5500.c b/drivers/regulator/ab5500.c
index af182f0c980..e8128e4caf8 100644
--- a/drivers/regulator/ab5500.c
+++ b/drivers/regulator/ab5500.c
@@ -58,6 +58,7 @@
struct ab5500_regulator {
struct regulator_desc desc;
const int *voltages;
+ int num_holes;
bool pwrctrl;
int enable_time;
u8 bank;
@@ -167,7 +168,10 @@ static int ab5500_regulator_get_voltage(struct regulator_dev *rdev)
}
regval &= AB5500_LDO_VOLT_MASK;
- if (regval >= r->desc.n_voltages || !r->voltages[regval])
+ if (regval >= r->desc.n_voltages + r->num_holes)
+ return -EINVAL;
+
+ if (!r->voltages[regval])
return -EINVAL;
return r->voltages[regval];
@@ -339,6 +343,7 @@ static struct ab5500_regulator ab5500_regulators[] = {
.bank = AB5500_BANK_STARTUP,
.reg = AB5500_LDO_L_ST,
.voltages = ab5500_ldo_lg_voltages,
+ .num_holes = 2, /* 2 register values unused */
.enable_time = 400,
},
[AB5500_LDO_G] = {
@@ -353,6 +358,7 @@ static struct ab5500_regulator ab5500_regulators[] = {
.bank = AB5500_BANK_STARTUP,
.reg = AB5500_LDO_G_ST,
.voltages = ab5500_ldo_lg_voltages,
+ .num_holes = 2, /* 2 register values unused */
.enable_time = 400,
},
[AB5500_LDO_K] = {