Skip to content

Commit f74521c

Browse files
myungjoobroonie
authored andcommitted
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 <[email protected]> Signed-off-by: MyungJoo Ham <[email protected]> Reviewed-by: Bartlomiej Zolnierkiewicz <[email protected]> Reviewed-by: Chanwoo Choi <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 2ea659a commit f74521c

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

drivers/regulator/max8997-regulator.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -428,12 +428,9 @@ static int max8997_set_voltage_charger_cv(struct regulator_dev *rdev,
428428
if (max_uV < 4000000 || min_uV > 4350000)
429429
return -EINVAL;
430430

431-
if (min_uV <= 4000000) {
432-
if (max_uV >= 4000000)
433-
return -EINVAL;
434-
else
435-
val = 0x1;
436-
} else if (min_uV <= 4200000 && max_uV >= 4200000)
431+
if (min_uV <= 4000000)
432+
val = 0x1;
433+
else if (min_uV <= 4200000 && max_uV >= 4200000)
437434
val = 0x0;
438435
else {
439436
lb = (min_uV - 4000001) / 20000 + 2;

0 commit comments

Comments
 (0)