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

Commit a5147abf authored by Anirudh Ghayal's avatar Anirudh Ghayal Committed by Sahil Chandna
Browse files

power: smb5-lib: Report smb_health based on CP status



The SMB temp reports a high value when CP is not enabled,
this leads SMB health to report an OVERHEAT status.
Avoid this by reporting UNKNOWN health status when CP
is not enabled.

Change-Id: I80ed9f7fb9d1d38b7c6a8eae9f8af9fb71a28fb1
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
Signed-off-by: default avatarSahil Chandna <chandna@codeaurora.org>
parent 6f79272a
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -3873,6 +3873,7 @@ int smblib_get_prop_smb_health(struct smb_charger *chg)
	int rc;
	u8 stat;
	int input_present;
	union power_supply_propval prop = {0, };

	rc = smblib_is_input_present(chg, &input_present);
	if (rc < 0)
@@ -3881,6 +3882,17 @@ int smblib_get_prop_smb_health(struct smb_charger *chg)
	if (input_present == INPUT_NOT_PRESENT)
		return POWER_SUPPLY_HEALTH_UNKNOWN;

	/*
	 * SMB health is used only for CP, report UNKNOWN if
	 * switcher is not enabled.
	 */
	if (is_cp_available(chg)) {
		rc = power_supply_get_property(chg->cp_psy,
			POWER_SUPPLY_PROP_CP_SWITCHER_EN, &prop);
		if (!rc && !prop.intval)
			return POWER_SUPPLY_HEALTH_UNKNOWN;
	}

	if (chg->wa_flags & SW_THERM_REGULATION_WA) {
		if (chg->smb_temp == -ENODATA)
			return POWER_SUPPLY_HEALTH_UNKNOWN;