From: MyungJoo Ham Date: Mon, 8 May 2017 05:45:44 +0000 (+0000) Subject: regulator: max8997/8966: fix charger cv voltage set bug X-Git-Tag: v4.14-rc1~615^2~1^5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f74521ca578f38daa3e800efde7fdb2ac3ba76ef;p=platform%2Fkernel%2Flinux-rpi.git regulator: max8997/8966: fix charger cv voltage set bug When min charger-CV is <= 4.0V and max charger-CV is >= 4.0V, we can use 4.00V as CV (register value = 0x1).` The original code had a typo that wrote ">=" (max_uV >= 4000000), which should've been "<", which is not necessary anyway as mentioned by Dan Carpenter. Reported-By: Dan Carpenter Signed-off-by: MyungJoo Ham Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Chanwoo Choi Signed-off-by: Mark Brown --- diff --git a/drivers/regulator/max8997-regulator.c b/drivers/regulator/max8997-regulator.c index efabc0e..559b9ac 100644 --- a/drivers/regulator/max8997-regulator.c +++ b/drivers/regulator/max8997-regulator.c @@ -428,12 +428,9 @@ static int max8997_set_voltage_charger_cv(struct regulator_dev *rdev, if (max_uV < 4000000 || min_uV > 4350000) return -EINVAL; - if (min_uV <= 4000000) { - if (max_uV >= 4000000) - return -EINVAL; - else - val = 0x1; - } else if (min_uV <= 4200000 && max_uV >= 4200000) + if (min_uV <= 4000000) + val = 0x1; + else if (min_uV <= 4200000 && max_uV >= 4200000) val = 0x0; else { lb = (min_uV - 4000001) / 20000 + 2;