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

Commit 01109ac3 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

qpnp-fg-gen3: Fix storing nominal capacity to actual capacity



Currently, nominal capacity is stored back to the actual capacity
only when the actual capacity is non-zero. However, that can be
true when the battery is inserted for the first time. This makes
the actual capacity to be stored only when a capacity learning
cycle completes. Other algorithms like to use actual capacity
before that. Fix it.

Change-Id: I346085ec722f491f96181ef1beb383710b441f4b
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent f410c920
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -912,10 +912,11 @@ static int fg_load_learned_cap_from_sram(struct fg_chip *chip)
	}

	chip->cl.learned_cc_uah = act_cap_mah * 1000;

	if (chip->cl.learned_cc_uah != chip->cl.nom_cap_uah) {
		if (chip->cl.learned_cc_uah == 0)
			chip->cl.learned_cc_uah = chip->cl.nom_cap_uah;

	if (chip->cl.learned_cc_uah != chip->cl.nom_cap_uah) {
		delta_cc_uah = abs(chip->cl.learned_cc_uah -
					chip->cl.nom_cap_uah);
		pct_nom_cap_uah = div64_s64((int64_t)chip->cl.nom_cap_uah *