Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e4a404a0 authored by H. Nikolaus Schaller's avatar H. Nikolaus Schaller Committed by Sebastian Reichel
Browse files

power:bq27xxx: 27000/10 read FLAGS register as single



The bq27000 and bq27010 have a single byte FLAGS register.
Other gauges have 16 bit FLAGS registers.

For reading the FLAGS register it is sufficient to read the single
register instead of reading RSOC at the next higher address as
well and then ignore the high byte.

This does not change functionality but optimizes i2c and hdq
traffic.

Signed-off-by: default avatarH. Nikolaus Schaller <hns@goldelico.com>
Acked-by: default avatarPali Rohár <pali.rohar@gmail.com>
Acked-by: default avatarAndrew F. Davis <afd@ti.com>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
parent 47d7d5ed
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -644,8 +644,9 @@ static bool bq27xxx_battery_dead(struct bq27xxx_device_info *di, u16 flags)
static int bq27xxx_battery_read_health(struct bq27xxx_device_info *di)
static int bq27xxx_battery_read_health(struct bq27xxx_device_info *di)
{
{
	int flags;
	int flags;
	bool has_singe_flag = di->chip == BQ27000 || di->chip == BQ27010;


	flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, false);
	flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, has_singe_flag);
	if (flags < 0) {
	if (flags < 0) {
		dev_err(di->dev, "error reading flag register:%d\n", flags);
		dev_err(di->dev, "error reading flag register:%d\n", flags);
		return flags;
		return flags;
@@ -745,7 +746,7 @@ static int bq27xxx_battery_current(struct bq27xxx_device_info *di,
	}
	}


	if (di->chip == BQ27000 || di->chip == BQ27010) {
	if (di->chip == BQ27000 || di->chip == BQ27010) {
		flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, false);
		flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, true);
		if (flags & BQ27000_FLAG_CHGS) {
		if (flags & BQ27000_FLAG_CHGS) {
			dev_dbg(di->dev, "negative current!\n");
			dev_dbg(di->dev, "negative current!\n");
			curr = -curr;
			curr = -curr;