]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
regulator: Fix the logic to ensure new voltage setting in valid range
authorAxel Lin <axel.lin@gmail.com>
Wed, 11 Apr 2012 12:53:58 +0000 (20:53 +0800)
committerBen Hutchings <ben@decadent.org.uk>
Sun, 20 May 2012 21:56:29 +0000 (22:56 +0100)
commit f55205f4d4a8823a11bb8b37ef2ecbd78fb09463 upstream.

I think this is a typo.
To ensure new voltage setting won't greater than desc->max,
the equation should be desc->min + desc->step * new_val <= desc->max.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/regulator/max8997.c

index 6176129a27e531e20c8921537798648c723f78ec..8cba82d3cadc940778d4274a24c2c76dabff13b7 100644 (file)
@@ -689,7 +689,7 @@ static int max8997_set_voltage_buck(struct regulator_dev *rdev,
                }
 
                new_val++;
-       } while (desc->min + desc->step + new_val <= desc->max);
+       } while (desc->min + desc->step * new_val <= desc->max);
 
        new_idx = tmp_idx;
        new_val = tmp_val;