aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMyungJoo Ham <myungjoo.ham@samsung.com>2017-05-08 01:45:44 -0400
committerMark Brown <broonie@kernel.org>2017-05-14 05:39:31 -0400
commitf74521ca578f38daa3e800efde7fdb2ac3ba76ef (patch)
tree615ace6fc9147aee877fdc43a4cefeeef14939b7
parent2ea659a9ef488125eb46da6eb571de5eae5c43f6 (diff)
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 <dan.carpenter@oracle.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com> Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/regulator/max8997-regulator.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/regulator/max8997-regulator.c b/drivers/regulator/max8997-regulator.c
index efabc0ea0e96..559b9ac45404 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,
428 if (max_uV < 4000000 || min_uV > 4350000) 428 if (max_uV < 4000000 || min_uV > 4350000)
429 return -EINVAL; 429 return -EINVAL;
430 430
431 if (min_uV <= 4000000) { 431 if (min_uV <= 4000000)
432 if (max_uV >= 4000000) 432 val = 0x1;
433 return -EINVAL; 433 else if (min_uV <= 4200000 && max_uV >= 4200000)
434 else
435 val = 0x1;
436 } else if (min_uV <= 4200000 && max_uV >= 4200000)
437 val = 0x0; 434 val = 0x0;
438 else { 435 else {
439 lb = (min_uV - 4000001) / 20000 + 2; 436 lb = (min_uV - 4000001) / 20000 + 2;