Skip to content

Commit cd060b4

Browse files
akemnadesre
authored andcommitted
power: supply: bq27xxx: fix polarity of current_now
current_now has to be negative during discharging and positive during charging, the behavior seen is the other way round. Tested on GTA04 with Openmoko battery. Signed-off-by: Andreas Kemnade <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 95b78d5 commit cd060b4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/power/supply/bq27xxx_battery.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,15 +1819,15 @@ static int bq27xxx_battery_current(struct bq27xxx_device_info *di,
18191819

18201820
if (di->opts & BQ27XXX_O_ZERO) {
18211821
flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, true);
1822-
if (flags & BQ27000_FLAG_CHGS) {
1822+
if (!(flags & BQ27000_FLAG_CHGS)) {
18231823
dev_dbg(di->dev, "negative current!\n");
18241824
curr = -curr;
18251825
}
18261826

18271827
val->intval = curr * BQ27XXX_CURRENT_CONSTANT / BQ27XXX_RS;
18281828
} else {
18291829
/* Other gauges return signed value */
1830-
val->intval = (int)((s16)curr) * 1000;
1830+
val->intval = -(int)((s16)curr) * 1000;
18311831
}
18321832

18331833
return 0;

0 commit comments

Comments
 (0)