power: vm_bms: avoid a race condition in the calculate_reported_soc
When the charging is ended, the last_soc may be set to invalid for a while. Add a check and do not calculate the reported soc if the last_soc value is invalid. Change-Id: Ia6987098dee5447c6852a276491930ddfbaa062e CRs-Fixed: 848209 Signed-off-by: Jie Cheng <rockiec@codeaurora.org>
This commit is contained in:
parent
a8d322f1ea
commit
987954e18e
|
@ -1974,6 +1974,11 @@ static void calculate_reported_soc(struct qpnp_bms_chip *chip)
|
|||
{
|
||||
union power_supply_propval ret = {0,};
|
||||
|
||||
if (chip->last_soc < 0) {
|
||||
pr_debug("last_soc is not ready, return\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (chip->reported_soc > chip->last_soc) {
|
||||
/*send DISCHARGING status if the reported_soc drops from 100 */
|
||||
if (chip->reported_soc == 100) {
|
||||
|
|
Loading…
Reference in New Issue