From 7b5ea4f9cfba344135634f876f47cd5f828a8bea Mon Sep 17 00:00:00 2001 From: litong20 Date: Wed, 15 Feb 2023 19:40:26 +0800 Subject: [PATCH] check the charger status again when devices shutdown. When the device shutdown due to unplugging the charger in factory mode, we need to check the status of the charger again. Change-Id: I43160b0802a700be88542427bad8a75fcd4a4e13 Reviewed-on: https://gerrit.mot.com/2512562 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Yonghua Yan Reviewed-by: Jianqi Yang Submit-Approved: Jira Key --- drivers/power/mmi_charger/mmi_charger.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/power/mmi_charger/mmi_charger.c b/drivers/power/mmi_charger/mmi_charger.c index de833ab1a3ca..3fd55305d4c1 100644 --- a/drivers/power/mmi_charger/mmi_charger.c +++ b/drivers/power/mmi_charger/mmi_charger.c @@ -53,6 +53,8 @@ module_param(factory_kill_disable, int, 0644); static int suspend_wakeups; module_param(suspend_wakeups, int, 0644); +static bool shutdown_triggered = false; + static struct mmi_charger_chip *this_chip = NULL; enum { @@ -2143,7 +2145,6 @@ static void mmi_charger_heartbeat_work(struct work_struct *work) heartbeat_work.work); struct timespec64 now; static struct timespec64 start; - static bool shutdown_triggered = false; uint32_t elapsed_ms; /* Have not been resumed so wait another 100 ms */ @@ -2595,7 +2596,8 @@ static int mmi_charger_reboot(struct notifier_block *nb, factory_kill_disable = true; chip->force_charger_disabled = true; schedule_delayed_work(&chip->heartbeat_work, msecs_to_jiffies(0)); - while (chip->max_charger_rate != MMI_POWER_SUPPLY_CHARGE_RATE_NONE) { + while (chip->max_charger_rate != MMI_POWER_SUPPLY_CHARGE_RATE_NONE && + shutdown_triggered && !chip->empty_vbat_shutdown_triggered) { mmi_info(chip, "Wait for charger removal\n"); msleep(100); }