power: pm8921-bms: Prevent SoC from rising during discharge
In a previous patch, scale_soc_while_chg was made to not be called when
catch_up_sec equals zero to prevent a kernel divide by zero bug.
However, this caused SoC to increase at times with multiple calls to
calculate_state_of_charge in quick succession.
Fix this by always calling scale_soc_while_chg and skip calculations only
when catch_up_sec is equal to zero.
Change-Id: Ic8c459aea41fde7f7b8762c51c3da71274bed16e
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
diff --git a/drivers/power/pm8921-bms.c b/drivers/power/pm8921-bms.c
index 7d44ebe..9c2898a 100644
--- a/drivers/power/pm8921-bms.c
+++ b/drivers/power/pm8921-bms.c
@@ -2478,8 +2478,7 @@
}
/* last_soc < soc ... scale and catch up */
- if (last_soc != -EINVAL && last_soc < soc && soc != 100
- && chip->catch_up_time_us != 0)
+ if (last_soc != -EINVAL && last_soc < soc && soc != 100)
soc = scale_soc_while_chg(chip, delta_time_us, soc, last_soc);
last_soc = soc;