From fefaa0821c428ec24eaf6354377b01bebbe8ae81 Mon Sep 17 00:00:00 2001 From: Kenny Kessler Date: Tue, 25 Jun 2019 10:00:38 -0500 Subject: [PATCH] power: qpnp-smbcharger-mmi: Wait for FG Ready IF the Max FG report -EAGAIN then it has not completed the init of the battery profile and values could be inaccurate. So stop processing and reschedule heartbeat if this is seen so a fresh 1st run of data can be taken. Change-Id: I2070ba9e90338b7eb2ba8eb4f395739170810012 Signed-off-by: Kenny Kessler Reviewed-on: https://gerrit.mot.com/1376495 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Cesar Augusto Marcelino dos Santos Reviewed-by: Ryan Lattrel Reviewed-by: Kenneth Kessler Submit-Approved: Jira Key --- drivers/power/qpnp-smbcharger-mmi/qpnp-smbcharger-mmi.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/power/qpnp-smbcharger-mmi/qpnp-smbcharger-mmi.c b/drivers/power/qpnp-smbcharger-mmi/qpnp-smbcharger-mmi.c index f3f811865740..93108ec67025 100644 --- a/drivers/power/qpnp-smbcharger-mmi/qpnp-smbcharger-mmi.c +++ b/drivers/power/qpnp-smbcharger-mmi/qpnp-smbcharger-mmi.c @@ -2706,6 +2706,12 @@ static void mmi_heartbeat_work(struct work_struct *work) } else flip_cap_full = pval.intval; + if (cap_err == -EAGAIN) { + mmi_err(chip, "SMBMMI: The FGs are not ready yet\n"); + hb_resch_time = HEARTBEAT_DUAL_DELAY_MS; + goto sch_hb; + } + report_cap = main_cap * main_cap_full; report_cap += flip_cap * flip_cap_full; report_cap /= main_cap_full + flip_cap_full;