power: qpnp-fg-gen4: Fix maintenance SOC reporting logic

Some times the SOC value reported as increasing even though
there is no charger connected to the device. Fix it by correcting
maintenance SOC reporting logic.

Change-Id: I0fb897616c72467f68b9be9a193c28a9008765ea
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
This commit is contained in:
Kiran Gunda 2020-02-05 14:43:02 +05:30 committed by Gerrit - the friendly Code Review server
parent 5e27b9d63f
commit 9b0f88c231

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -2641,14 +2641,14 @@ static int fg_gen4_update_maint_soc(struct fg_dev *fg)
goto out;
}
if (msoc > fg->maint_soc) {
if (msoc >= fg->maint_soc) {
/*
* When the monotonic SOC goes above maintenance SOC, we should
* stop showing the maintenance SOC.
*/
fg->delta_soc = 0;
fg->maint_soc = 0;
} else if (fg->maint_soc && msoc <= fg->last_msoc) {
} else if (fg->maint_soc && msoc < fg->last_msoc) {
/* MSOC is decreasing. Decrease maintenance SOC as well */
fg->maint_soc -= 1;
if (!(msoc % 10)) {