Message ID | 20200315151206.30909-2-spinal.by@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [01/15] power: supply: cpcap-battery: Fix battery full status reporting | expand |
* Arthur Demchenkov <spinal.by@gmail.com> [200315 15:15]: > If the battery status is detected as full for the charging current that > doesn't exceed 100 mA, it will then be reported as full for charging > currents in the range of 100-150 mA. This is needed because > charge_current value has a spread. > > We don't use avg_current here because it can trigger wrong battery full > status on charger connected event. Hmm oh so this is against my earlier RFC patches. Care to respin the series against v5.6-rc? Feel free tweak my patches to leave out the unnecessary stuff as we decided to do things in a better way :) Just add a note like: [spinal: dropped out unusable foo and bar] So we know what got changed compared to the RFC patches. And then we might have a nice working set for merging in subject to others approving this approach of course :) Regards, Tony
diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c index 34a9dbcd1a23..52f03a2662a5 100644 --- a/drivers/power/supply/cpcap-battery.c +++ b/drivers/power/supply/cpcap-battery.c @@ -406,13 +406,16 @@ static int cpcap_battery_cc_get_avg_current(struct cpcap_battery_ddata *ddata) static bool cpcap_battery_full(struct cpcap_battery_ddata *ddata) { struct cpcap_battery_state_data *state = cpcap_battery_latest(ddata); + static bool is_full; if (state->voltage >= (ddata->config.bat.constant_charge_voltage_max_uv - 18000) && - state->current_ua > -100000) - return true; + state->current_ua > (is_full ? -150000 : -100000)) + is_full = true; + else + is_full = false; - return false; + return is_full; } static bool cpcap_battery_low(struct cpcap_battery_ddata *ddata)
If the battery status is detected as full for the charging current that doesn't exceed 100 mA, it will then be reported as full for charging currents in the range of 100-150 mA. This is needed because charge_current value has a spread. We don't use avg_current here because it can trigger wrong battery full status on charger connected event. Signed-off-by: Arthur Demchenkov <spinal.by@gmail.com> --- drivers/power/supply/cpcap-battery.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)