diff options
author | Rabin Vincent <rabin.vincent@stericsson.com> | 2011-05-06 16:13:46 +0530 |
---|---|---|
committer | Philippe Langlais <philippe.langlais@linaro.org> | 2011-07-22 15:46:10 +0200 |
commit | 6bda842e788f700c1569e9eabb7bcebbddfef8d4 (patch) | |
tree | 274d4c78de92981873739ebb7e243eca4f3d22d7 | |
parent | a3ed8b765ddd0a5c26e22415e948e31660ecae9d (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.c | 8 |
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] = { |