From 371c451d08badeff653441a44b03e63e5f8303b6 Mon Sep 17 00:00:00 2001 From: Subbaraman Narayanamurthy Date: Thu, 21 Dec 2017 17:39:07 -0800 Subject: [PATCH] power: qpnp-fg-gen3: Adjust recharge SOC after early termination Currently, recharge SOC is adjusted based on the SOC at which charge termination occurs. However, it gets reset back to the original threshold only if input is removed. This does not work well if charging resumes again once the battery is out of JEITA as the recharge SOC threshold stays configured at a lower value. Fix it by adjusting recharge SOC to the original threshold once charging begins. CRs-Fixed: 2163058 Change-Id: I07c714d32ba0005d3b0ff61142928eda58f049d0 Signed-off-by: Subbaraman Narayanamurthy --- drivers/power/supply/qcom/qpnp-fg-gen3.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/qcom/qpnp-fg-gen3.c b/drivers/power/supply/qcom/qpnp-fg-gen3.c index 2f958a3438ee..2b645e8b7028 100644 --- a/drivers/power/supply/qcom/qpnp-fg-gen3.c +++ b/drivers/power/supply/qcom/qpnp-fg-gen3.c @@ -2093,8 +2093,12 @@ static int fg_adjust_recharge_soc(struct fg_chip *chip) return 0; } } else { - /* Charging, do nothing */ - return 0; + if (!chip->recharge_soc_adjusted) + return 0; + + /* Restore the default value */ + new_recharge_soc = recharge_soc; + chip->recharge_soc_adjusted = false; } } else { /* Restore the default value */