power: qpnp-fg-gen3: Get the raw MSOC directly from FG register

Use the MSOC raw value directly from the register instead of
extrapolating it from MSOC value to avoid any rounding-off
errors.

CRs-Fixed: 2080211
Change-Id: I91d98c6aa8a63344ff79b5414c45d0f5a5b52b81
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
This commit is contained in:
Anirudh Ghayal 2017-08-08 14:47:56 +05:30
parent 58274ed8f1
commit 5a343c279b

View file

@ -1680,12 +1680,12 @@ static int fg_charge_full_update(struct fg_chip *chip)
/* We need 2 most significant bytes here */
bsoc = (u32)bsoc >> 16;
rc = fg_get_msoc(chip, &msoc);
rc = fg_get_msoc_raw(chip, &msoc_raw);
if (rc < 0) {
pr_err("Error in getting msoc, rc=%d\n", rc);
pr_err("Error in getting msoc_raw, rc=%d\n", rc);
goto out;
}
msoc_raw = DIV_ROUND_CLOSEST(msoc * FULL_SOC_RAW, FULL_CAPACITY);
msoc = DIV_ROUND_CLOSEST(msoc_raw * FULL_CAPACITY, FULL_SOC_RAW);
fg_dbg(chip, FG_STATUS, "msoc: %d bsoc: %x health: %d status: %d full: %d\n",
msoc, bsoc, chip->health, chip->charge_status,