From: Axel Lin Date: Wed, 11 Apr 2012 12:53:58 +0000 (+0800) Subject: regulator: Fix the logic to ensure new voltage setting in valid range X-Git-Tag: v3.0.32~46 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=efa80b562ab2afeb1130205ae8190fccf079506c;p=users%2Fdwmw2%2Flinux.git regulator: Fix the logic to ensure new voltage setting in valid range 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 Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index ad6628ca94f41..a8fb668c03a84 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c @@ -688,7 +688,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;