mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-09-21 07:01:57 +00:00
power: pfuze100: Fix off by one error in voltage table handling
The code that sets a regulator by looking up the voltage in a table had an off by one error. vsel_mask is a bitmask, not the number of table entries, so a vsel_mask value of 0x7 indicates there are 8, not 7, entries in the table. Cc: Peng Fan <Peng.Fan@freescale.com> Cc: Jaehoon Chung <jh80.chung@samsung.com> Signed-off-by: Trent Piepho <tpiepho@impinj.com>
This commit is contained in:
parent
15bae9a86d
commit
d3eaf95ec6
1 changed files with 2 additions and 2 deletions
|
@ -482,11 +482,11 @@ static int pfuze100_regulator_val(struct udevice *dev, int op, int *uV)
|
||||||
debug("Set voltage for REGULATOR_TYPE_FIXED regulator\n");
|
debug("Set voltage for REGULATOR_TYPE_FIXED regulator\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
} else if (desc->volt_table) {
|
} else if (desc->volt_table) {
|
||||||
for (i = 0; i < desc->vsel_mask; i++) {
|
for (i = 0; i <= desc->vsel_mask; i++) {
|
||||||
if (*uV == desc->volt_table[i])
|
if (*uV == desc->volt_table[i])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i == desc->vsel_mask) {
|
if (i == desc->vsel_mask + 1) {
|
||||||
debug("Unsupported voltage %u\n", *uV);
|
debug("Unsupported voltage %u\n", *uV);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue