From: xuwei9 Date: Wed, 10 Apr 2019 10:29:33 +0000 (+0800) Subject: kernel:report cable attch event three thime X-Git-Tag: MMI-RSBS31.Q1-48-36-26~188 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e3b65408ee34c5b752ae234123c1d863389836cd;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git kernel:report cable attch event three thime samsung report cable attach event three times which result in battery status override Change-Id: I6ae9dd37d369254d15b1d5678dcb1a0d79dcb8a7 Signed-off-by: xuwei9 Reviewed-on: https://gerrit.mot.com/1334878 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Zonghua Liu Reviewed-by: Hua Tan Submit-Approved: Jira Key --- diff --git a/drivers/power/supply/s2mu00x_battery.c b/drivers/power/supply/s2mu00x_battery.c index 7d65a069972f..5c5b355e78c6 100644 --- a/drivers/power/supply/s2mu00x_battery.c +++ b/drivers/power/supply/s2mu00x_battery.c @@ -476,6 +476,7 @@ struct s2mu00x_battery_info { bool enable_factory_wa; int max_chrg_temp; bool charging_disabled; + int cable_attach_flag; }; static int is_charging_mode = S2MU00X_NOR_MODE; @@ -1661,12 +1662,14 @@ end_ifconn_handle: smbchg_relax(battery); cancel_delayed_work_sync(&battery->heartbeat_work); battery->stepchg_state = STEP_NONE; + battery->cable_attach_flag = 0; battery->charging_limit_modes = CHARGING_LIMIT_OFF; set_max_allowed_current_ma(battery,battery->stepchg_current_ma); battery->charger_rate = POWER_SUPPLY_CHARGE_RATE_NONE; } else { battery->charger_rate = POWER_SUPPLY_CHARGE_RATE_NORMAL; smbchg_stay_awake(battery); + battery->cable_attach_flag = 1; cancel_delayed_work(&battery->heartbeat_work); schedule_delayed_work(&battery->heartbeat_work, msecs_to_jiffies(0)); } @@ -4123,9 +4126,11 @@ static void smbchg_heartbeat_work(struct work_struct *work) if ((prev_batt_health != chip->temp_state) || (prev_ext_lvl != chip->ext_high_temp) || (prev_step != chip->stepchg_state) || - (chip->update_allowed_fastchg_current_ma)) { + (chip->update_allowed_fastchg_current_ma) || + (chip->cable_attach_flag == 1)) { pr_info("%s, temp state: %d\n", __func__, chip->temp_state); + chip->cable_attach_flag = 0; smbchg_set_temp_chgpath(chip, prev_batt_health); if (chip->stepchg_state == STEP_MAX) set_max_allowed_current_ma(chip, @@ -4538,6 +4543,7 @@ static int s2mu00x_battery_probe(struct platform_device *pdev) battery->test_mode_temp = DEFAULT_TEST_MODE_TEMP; battery->test_mode = qpnp_smbcharger_test_mode(); battery->max_chrg_temp = 0; + battery->cable_attach_flag = 0; if (battery->test_mode) pr_err("Test Mode Enabled\n"); battery->is_weak_charger = false;