mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-23 12:43:55 +08:00
bq27x00: use cached flags
The flags were just read by bq27xxx_battery_update(), no need to read them again. Signed-off-by: Arthur Demchenkov <spinal.by@gmail.com> Reviewed-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
parent
74f0aaba7c
commit
9b2c945f9f
@ -1555,27 +1555,14 @@ static bool bq27xxx_battery_dead(struct bq27xxx_device_info *di, u16 flags)
|
||||
return flags & (BQ27XXX_FLAG_SOC1 | BQ27XXX_FLAG_SOCF);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read flag register.
|
||||
* Return < 0 if something fails.
|
||||
*/
|
||||
static int bq27xxx_battery_read_health(struct bq27xxx_device_info *di)
|
||||
{
|
||||
int flags;
|
||||
bool has_singe_flag = di->opts & BQ27XXX_O_ZERO;
|
||||
|
||||
flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, has_singe_flag);
|
||||
if (flags < 0) {
|
||||
dev_err(di->dev, "error reading flag register:%d\n", flags);
|
||||
return flags;
|
||||
}
|
||||
|
||||
/* Unlikely but important to return first */
|
||||
if (unlikely(bq27xxx_battery_overtemp(di, flags)))
|
||||
if (unlikely(bq27xxx_battery_overtemp(di, di->cache.flags)))
|
||||
return POWER_SUPPLY_HEALTH_OVERHEAT;
|
||||
if (unlikely(bq27xxx_battery_undertemp(di, flags)))
|
||||
if (unlikely(bq27xxx_battery_undertemp(di, di->cache.flags)))
|
||||
return POWER_SUPPLY_HEALTH_COLD;
|
||||
if (unlikely(bq27xxx_battery_dead(di, flags)))
|
||||
if (unlikely(bq27xxx_battery_dead(di, di->cache.flags)))
|
||||
return POWER_SUPPLY_HEALTH_DEAD;
|
||||
|
||||
return POWER_SUPPLY_HEALTH_GOOD;
|
||||
@ -1612,6 +1599,7 @@ void bq27xxx_battery_update(struct bq27xxx_device_info *di)
|
||||
cache.capacity = bq27xxx_battery_read_soc(di);
|
||||
if (di->regs[BQ27XXX_REG_AE] != INVALID_REG_ADDR)
|
||||
cache.energy = bq27xxx_battery_read_energy(di);
|
||||
di->cache.flags = cache.flags;
|
||||
cache.health = bq27xxx_battery_read_health(di);
|
||||
}
|
||||
if (di->regs[BQ27XXX_REG_CYCT] != INVALID_REG_ADDR)
|
||||
|
Loading…
Reference in New Issue
Block a user