Skip to content

Commit e2b018c

Browse files
sicelosre
authored andcommitted
power: supply: bq27xxx: fix reporting critical level
The EDV1/SOC1 flag is set when the battery voltage drops below the threshold set in EEPROM. From observing the capacity_level reported by the driver, and reading the datasheet, EDV1 remains set even when EDVF/SOCF gets set. Thus, bq27xxx_battery_capacity_level() never reaches the CAPACITY_LEVEL_CRITICAL code path, since CAPACITY_LEVEL_LOW takes precedence. This commit fixes the issue by swapping the order in which the flags are tested. It was tested with bq27200 in the Nokia N900. Signed-off-by: Sicelo A. Mhlongo <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 4651b6b commit e2b018c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/power/supply/bq27xxx_battery.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,10 +1917,10 @@ static int bq27xxx_battery_capacity_level(struct bq27xxx_device_info *di,
19171917
if (di->opts & BQ27XXX_O_ZERO) {
19181918
if (di->cache.flags & BQ27000_FLAG_FC)
19191919
level = POWER_SUPPLY_CAPACITY_LEVEL_FULL;
1920-
else if (di->cache.flags & BQ27000_FLAG_EDV1)
1921-
level = POWER_SUPPLY_CAPACITY_LEVEL_LOW;
19221920
else if (di->cache.flags & BQ27000_FLAG_EDVF)
19231921
level = POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL;
1922+
else if (di->cache.flags & BQ27000_FLAG_EDV1)
1923+
level = POWER_SUPPLY_CAPACITY_LEVEL_LOW;
19241924
else
19251925
level = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL;
19261926
} else if (di->opts & BQ27Z561_O_BITS) {
@@ -1933,10 +1933,10 @@ static int bq27xxx_battery_capacity_level(struct bq27xxx_device_info *di,
19331933
} else {
19341934
if (di->cache.flags & BQ27XXX_FLAG_FC)
19351935
level = POWER_SUPPLY_CAPACITY_LEVEL_FULL;
1936-
else if (di->cache.flags & BQ27XXX_FLAG_SOC1)
1937-
level = POWER_SUPPLY_CAPACITY_LEVEL_LOW;
19381936
else if (di->cache.flags & BQ27XXX_FLAG_SOCF)
19391937
level = POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL;
1938+
else if (di->cache.flags & BQ27XXX_FLAG_SOC1)
1939+
level = POWER_SUPPLY_CAPACITY_LEVEL_LOW;
19401940
else
19411941
level = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL;
19421942
}

0 commit comments

Comments
 (0)