regulator: rc5t583: Fix off-by-one valid range checking for selector
The valid selector should be 0 ... nsteps-1. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
7eb6444fc3
commit
9cc7a453b6
|
@ -131,7 +131,7 @@ static int rc5t583_set_voltage_sel(struct regulator_dev *rdev,
|
||||||
struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);
|
struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);
|
||||||
struct rc5t583_regulator_info *ri = reg->reg_info;
|
struct rc5t583_regulator_info *ri = reg->reg_info;
|
||||||
int ret;
|
int ret;
|
||||||
if (selector > ri->nsteps) {
|
if (selector >= ri->nsteps) {
|
||||||
dev_err(&rdev->dev, "Invalid selector 0x%02x\n", selector);
|
dev_err(&rdev->dev, "Invalid selector 0x%02x\n", selector);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue