From a8cb200aab5fc88734a20f75f4d7e6790674d6f7 Mon Sep 17 00:00:00 2001 From: litong Date: Sun, 23 Apr 2023 05:19:12 -0500 Subject: [PATCH] Revert "(CR): Ensuring monotonic variation of soc" Revert: This reverts commit daaaf64b38c53308fba2615213bacc64bcdb8bd0. Change-Id: I8e75ac6d8753f68c0fb542df3b307f9ad77fed82 Reviewed-on: https://gerrit.mot.com/2586578 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Wentao Xu Reviewed-by: Guobin Zhang Submit-Approved: Jira Key --- drivers/power/mmi_charger/mmi_charger.c | 51 ++++++++++--------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/drivers/power/mmi_charger/mmi_charger.c b/drivers/power/mmi_charger/mmi_charger.c index 97dfe0865b14..3fd55305d4c1 100644 --- a/drivers/power/mmi_charger/mmi_charger.c +++ b/drivers/power/mmi_charger/mmi_charger.c @@ -1813,6 +1813,27 @@ static int mmi_get_battery_health(struct mmi_charger *charger) return batt_health; } +static int mmi_combine_battery_soc(struct mmi_charger_chip *chip) +{ + int soc = 0; + int remain = 0, full = 0; + struct mmi_battery_pack *battery = NULL; + + list_for_each_entry(battery, &chip->battery_list, list) { + remain += battery->info->batt_soc * battery->info->batt_full_uah; + full += battery->info->batt_full_uah; + } + + if (full > 0 && remain >= 0) { + soc = remain / full; + if (soc > 100) + soc = 100; + } else + soc = -1; + + return soc; +} + static int mmi_combine_battery_status(struct mmi_charger_chip *chip) { int status = POWER_SUPPLY_STATUS_UNKNOWN; @@ -1839,36 +1860,6 @@ static int mmi_combine_battery_status(struct mmi_charger_chip *chip) return status; } -static int mmi_combine_battery_soc(struct mmi_charger_chip *chip) -{ - int status; - static int soc = 0; - int soc_curr = 0; - int remain = 0, full = 0; - struct mmi_battery_pack *battery = NULL; - - list_for_each_entry(battery, &chip->battery_list, list) { - remain += battery->info->batt_soc * battery->info->batt_full_uah; - full += battery->info->batt_full_uah; - } - - if (full > 0 && remain >= 0) { - soc_curr = remain / full; - status = mmi_combine_battery_status(chip); - if ((soc <= 0) || - ((status == POWER_SUPPLY_STATUS_CHARGING) && (soc_curr > soc)) || - ((status != POWER_SUPPLY_STATUS_CHARGING) && (soc_curr < soc))) { - soc = soc_curr; - } - - if (soc > 100) - soc = 100; - } else - soc = -1; - - return soc; -} - static int mmi_combine_battery_cycles(struct mmi_charger_chip *chip) { int cycles = 0;