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

Commit 5f46dd69 authored by Kiran Gunda's avatar Kiran Gunda
Browse files

power: smb5-lib: Report NOT_CHARGING in over voltage condition



Currently the charger status shows as charging when the over
voltage condition is hit even though the battery is actually
discharging. Fix it by reporting the power supply status as
NOT_CHARGING when the battery health reports over voltage.

Change-Id: If551e51fd506d3f3df93d1a609d20add0631b228
Signed-off-by: default avatarKiran Gunda <kgunda@codeaurora.org>
parent 50fddb39
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -1983,6 +1983,22 @@ int smblib_get_prop_batt_status(struct smb_charger *chg,
		}
	}

	rc = smblib_get_prop_batt_health(chg, &pval);
	if (rc < 0) {
		smblib_err(chg, "Couldn't get batt health rc=%d\n", rc);
		return rc;
	}
	/*
	 * The charger status register shows charging even though the battery
	 * is discharging when the over voltage condition is hit. Report power
	 * supply state as NOT_CHARGING when the battery health reports
	 * over voltage.
	 */
	if (pval.intval == POWER_SUPPLY_HEALTH_OVERVOLTAGE) {
		val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
		return 0;
	}

	if (chg->dbc_usbov) {
		rc = smblib_get_prop_usb_present(chg, &pval);
		if (rc < 0) {