From fd3c66b1b0633ccbd57adbe1f44f4026454bfd81 Mon Sep 17 00:00:00 2001 From: Yonghua Yan Date: Mon, 30 Jan 2023 16:28:00 +0800 Subject: [PATCH] Initialize the delay work before IRQ init Initialize the delay work before IRQ init in case the irq occurs to schedule the delay work before it initialized and cause Kernel panic. Change-Id: I9497e4ca66193d9f9170b666dd15a9fed9fd890b Signed-off-by: Yonghua Yan Reviewed-on: https://gerrit.mot.com/2497207 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: litong Reviewed-by: Huosheng Liao Submit-Approved: Jira Key --- drivers/power/sgm4154x_charger_lite/sgm4154x_charger_lite.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/power/sgm4154x_charger_lite/sgm4154x_charger_lite.c b/drivers/power/sgm4154x_charger_lite/sgm4154x_charger_lite.c index 017df5c872e2..2aa85be70cb5 100644 --- a/drivers/power/sgm4154x_charger_lite/sgm4154x_charger_lite.c +++ b/drivers/power/sgm4154x_charger_lite/sgm4154x_charger_lite.c @@ -3390,6 +3390,9 @@ static int sgm4154x_probe(struct i2c_client *client, otg_notify = usb_register_notifier(sgm->usb3_phy, &sgm->usb_nb); } + INIT_DELAYED_WORK(&sgm->charge_detect_delayed_work, charger_detect_work_func); + INIT_DELAYED_WORK(&sgm->charge_monitor_work, charger_monitor_work_func); + if (client->irq) { ret = devm_request_threaded_irq(dev, client->irq, NULL, sgm4154x_irq_handler_thread, @@ -3402,8 +3405,6 @@ static int sgm4154x_probe(struct i2c_client *client, sgm->irq_enabled = true; } - INIT_DELAYED_WORK(&sgm->charge_detect_delayed_work, charger_detect_work_func); - INIT_DELAYED_WORK(&sgm->charge_monitor_work, charger_monitor_work_func); sgm->pm_nb.notifier_call = sgm4154x_suspend_notifier; register_pm_notifier(&sgm->pm_nb); sgm->psy_nb.notifier_call = sgm4154x_psy_notifier_call;