regulator: rc5t583: Fix off-by-one valid range checking for selector
authorAxel Lin <axel.lin@gmail.com>
Wed, 4 Apr 2012 14:38:09 +0000 (22:38 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 5 Apr 2012 10:02:44 +0000 (11:02 +0100)
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>
drivers/regulator/rc5t583-regulator.c

index cac8a2a4f8e600b7c98450b5aa849ce5bcbbd259..dc9ebb9bfd23de6d866e2566789a7bdda932648b 100644 (file)
@@ -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_info *ri = reg->reg_info;
        int ret;
-       if (selector > ri->nsteps) {
+       if (selector >= ri->nsteps) {
                dev_err(&rdev->dev, "Invalid selector 0x%02x\n", selector);
                return -EINVAL;
        }