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

Commit 3f4c6bbd authored by Harry Yang's avatar Harry Yang
Browse files

power: qpnp-fg-gen4: Fix esr_delta bounding error



During ESR calibration, a bounded function of esr_delta mistakenly
returns upper or lower bound, which eventually leads to large SOC
inaccuracy.

Fix it.

CRs-Fixed: 2282679
Change-Id: I70096b56c4b862cd9abf22aa799c952fb916d1d5
Signed-off-by: default avatarHarry Yang <harryy@codeaurora.org>
parent 986a6c68
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2589,9 +2589,9 @@ static void esr_calib_work(struct work_struct *work)
	esr_delta = esr_delta - esr_filtered;

	/* Bound the limits */
	if (esr_delta < SHRT_MAX)
	if (esr_delta > SHRT_MAX)
		esr_delta = SHRT_MAX;
	else if (esr_delta > SHRT_MIN)
	else if (esr_delta < SHRT_MIN)
		esr_delta = SHRT_MIN;

	fg_dbg(fg, FG_STATUS, "fg_esr_meas_diff: 0x%x esr_filt: 0x%x esr_delta_new: 0x%x\n",