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

Commit afb80e7a authored by Anirudh Ghayal's avatar Anirudh Ghayal Committed by Umang Agrawal
Browse files

power: qpnp-qg: Cap the SOC at PON



There is a possibility of a SOC overflow when the
lookup PON (sys) soc is 100%, fix this by capping the
SOC to 100.

Change-Id: I84865b3f459b8b0d4a3eeac5418c66ad57fe80f1
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent 3223cf13
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -2894,11 +2894,13 @@ static int qg_determine_pon_soc(struct qpnp_qg *chip)
			goto done;
		}

		if ((full_soc > cutoff_soc) && (pon_soc > cutoff_soc))
		if ((full_soc > cutoff_soc) && (pon_soc > cutoff_soc)) {
			soc = DIV_ROUND_UP(((pon_soc - cutoff_soc) * 100),
						(full_soc - cutoff_soc));
		else
			soc = CAP(0, 100, soc);
		} else {
			soc = pon_soc;
		}

		qg_dbg(chip, QG_DEBUG_PON, "v_float=%d v_cutoff=%d FULL_SOC=%d CUTOFF_SOC=%d PON_SYS_SOC=%d pon_soc=%d\n",
			chip->bp.float_volt_uv, chip->dt.vbatt_cutoff_mv * 1000,