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

Commit 6ed3546d authored by Harry Yang's avatar Harry Yang
Browse files

power: smblib: fix die temp state reporting



Currently, TEMP_RANGE bits in TEMP_RANGE_STATUS_REG are assumed
mutually exclusive and unknown state is reported when more than
one bits are set.

Fix it by checking each individual bit in order.

CRs-Fixed: 2143543
Change-Id: I2cbec08cad22ce4f9575e703144f04a3be4eced0
Signed-off-by: default avatarHarry Yang <harryy@codeaurora.org>
parent ade6ec4d
Loading
Loading
Loading
Loading
+8 −15
Original line number Diff line number Diff line
@@ -2539,23 +2539,16 @@ int smblib_get_prop_die_health(struct smb_charger *chg,
		return rc;
	}

	/* TEMP_RANGE bits are mutually exclusive */
	switch (stat & TEMP_RANGE_MASK) {
	case TEMP_BELOW_RANGE_BIT:
		val->intval = POWER_SUPPLY_HEALTH_COOL;
		break;
	case TEMP_WITHIN_RANGE_BIT:
		val->intval = POWER_SUPPLY_HEALTH_WARM;
		break;
	case TEMP_ABOVE_RANGE_BIT:
		val->intval = POWER_SUPPLY_HEALTH_HOT;
		break;
	case ALERT_LEVEL_BIT:
	if (stat & ALERT_LEVEL_BIT)
		val->intval = POWER_SUPPLY_HEALTH_OVERHEAT;
		break;
	default:
	else if (stat & TEMP_ABOVE_RANGE_BIT)
		val->intval = POWER_SUPPLY_HEALTH_HOT;
	else if (stat & TEMP_WITHIN_RANGE_BIT)
		val->intval = POWER_SUPPLY_HEALTH_WARM;
	else if (stat & TEMP_BELOW_RANGE_BIT)
		val->intval = POWER_SUPPLY_HEALTH_COOL;
	else
		val->intval = POWER_SUPPLY_HEALTH_UNKNOWN;
	}

	return 0;
}