From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-m49197.qiye.163.com (mail-m49197.qiye.163.com [45.254.49.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD8BF39D3FD for ; Sun, 19 Jul 2026 14:44:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784472246; cv=none; b=PlHQhP6aOiP4dmtrYm2eGQXYY8DZHhLndOxojXDoc8waf9kYIH+FU9gg5u1zqIJo/u+vzG5z23v+uCj9bD6xNVteJHhw4hyHSOSkngLzFGTE/0NTuraOu1AZjzRJvIyR1KDXr1VAbShCmHwQ6RA5Dg+KpqBUudSo4zkGY+/4XKo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784472246; c=relaxed/simple; bh=QFG5MW2tFNri1VgZIDdxKjP1GWlGBM0Tndo+LnjKHmo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Ou1RBQd7Ohi6PVvDE8Zye6bI68D4pUUNc88hyC2BNMNbNEFfMnzGRAVy7vUfww6OoSkS+x3XZj33PXOiiGE2ufPUtX8fEMjdL/+ZAExFvsg/UrZ8pZI2/19CnhoYS8oENA2sgIvHe3ppeK0ooAQ5NyTsHqjAUEtC468KO2YYpyQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=seu.edu.cn; spf=pass smtp.mailfrom=seu.edu.cn; dkim=pass (1024-bit key) header.d=seu.edu.cn header.i=@seu.edu.cn header.b=KMha7Q+y; arc=none smtp.client-ip=45.254.49.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=seu.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=seu.edu.cn Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=seu.edu.cn header.i=@seu.edu.cn header.b="KMha7Q+y" Received: from LAPTOP-99KJFSET (unknown [222.191.246.242]) by smtp.qiye.163.com (Hmail) with ESMTP id 46bb6c3ce; Sun, 19 Jul 2026 22:43:54 +0800 (GMT+08:00) From: Hongyan Xu To: cw00.choi@samsung.com, krzysztof.kozlowski@linaro.org, myungjoo.ham@samsung.com Cc: linux-kernel@vger.kernel.org, jianhao.xu@seu.edu.cn, getshell@seu.edu.cn Subject: [PATCH] extcon: max14577: cancel cable detection work on detach Date: Sun, 19 Jul 2026 22:43:52 +0800 Message-ID: <20260719144352.598-1-getshell@seu.edu.cn> X-Mailer: git-send-email 2.50.1.windows.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Tid: 0a9f7ad569e403a1kunm46ef98069555b X-HM-MType: 10 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWRgWCB1ZQUpXWS1ZQUlXWQ8JGhUIEh9ZQVkZHk1LVk9ITU8ZHR0fSBhLH1YeHw 5VEwETFhoSFyQUDg9ZV1kYEgtZQVlJSUlVSkJKVUlPTVVJT0lZV1kWGg8SFR0UWUFZT0tIVUpLSU hOQ0NVSktLVUtZBg++ DKIM-Signature: a=rsa-sha256; b=KMha7Q+yJmz17UteB28RsHbw6zSwR/GxFtNB2J1DBptwvUw/sGH9YKNBspFUuKLCDbzHa7ieec9cNeO5UYVxNXNoOA5cqYVoHAZL14D7eYhRivT+rc35Q54ub16AAqNY0yvkWS84S5JlBXM1rZaZTJlroxDBGJ+/21q1/VyVXVk=; s=default; c=relaxed/relaxed; d=seu.edu.cn; v=1; bh=S+eVI73smzB7a5F+Z4GEBSn+AjBLJMk2yFHNSsvzIbQ=; h=date:mime-version:subject:message-id:from; Probe queues wq_detcable, but the delayed work is not cancelled when the platform device is detached. Devres can therefore release info while the work is still pending. Manage both work items with devres and request the nested IRQs only after the extcon device and work items are ready. Reverse-order release then stops the IRQ producers before cancelling the work and releasing info. Signed-off-by: Hongyan Xu --- drivers/extcon/extcon-max14577.c | 58 +++++++++++++++++--------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c index 5476f48..9fad5c9 100644 --- a/drivers/extcon/extcon-max14577.c +++ b/drivers/extcon/extcon-max14577.c @@ -674,11 +674,6 @@ static int max14577_muic_probe(struct platform_device *pdev) platform_set_drvdata(pdev, info); mutex_init(&info->mutex); - ret = devm_work_autocancel(&pdev->dev, &info->irq_work, - max14577_muic_irq_work); - if (ret) - return ret; - switch (max14577->dev_type) { case MAXIM_DEVICE_TYPE_MAX77836: info->muic_irqs = max77836_muic_irqs; @@ -690,28 +685,6 @@ static int max14577_muic_probe(struct platform_device *pdev) info->muic_irqs_num = ARRAY_SIZE(max14577_muic_irqs); } - /* Support irq domain for max14577 MUIC device */ - for (i = 0; i < info->muic_irqs_num; i++) { - struct max14577_muic_irq *muic_irq = &info->muic_irqs[i]; - int virq = 0; - - virq = regmap_irq_get_virq(max14577->irq_data, muic_irq->irq); - if (virq <= 0) - return -EINVAL; - muic_irq->virq = virq; - - ret = devm_request_threaded_irq(&pdev->dev, virq, NULL, - max14577_muic_irq_handler, - IRQF_NO_SUSPEND, - muic_irq->name, info); - if (ret) { - dev_err(&pdev->dev, - "failed: irq request (IRQ: %d, error :%d)\n", - muic_irq->irq, ret); - return ret; - } - } - /* Initialize extcon device */ info->edev = devm_extcon_dev_allocate(&pdev->dev, max14577_extcon_cable); @@ -725,6 +698,14 @@ static int max14577_muic_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to register extcon device\n"); return ret; } + ret = devm_work_autocancel(&pdev->dev, &info->irq_work, + max14577_muic_irq_work); + if (ret) + return ret; + ret = devm_delayed_work_autocancel(&pdev->dev, &info->wq_detcable, + max14577_muic_detect_cable_wq); + if (ret) + return ret; /* Default h/w line path */ info->path_usb = CTRL1_SW_USB; @@ -755,6 +736,28 @@ static int max14577_muic_probe(struct platform_device *pdev) /* Set ADC debounce time */ max14577_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS); + /* Support irq domain for max14577 MUIC device */ + for (i = 0; i < info->muic_irqs_num; i++) { + struct max14577_muic_irq *muic_irq = &info->muic_irqs[i]; + int virq = 0; + + virq = regmap_irq_get_virq(max14577->irq_data, muic_irq->irq); + if (virq <= 0) + return -EINVAL; + muic_irq->virq = virq; + + ret = devm_request_threaded_irq(&pdev->dev, virq, NULL, + max14577_muic_irq_handler, + IRQF_NO_SUSPEND, + muic_irq->name, info); + if (ret) { + dev_err(&pdev->dev, + "failed: irq request (IRQ: %d, error :%d)\n", + muic_irq->irq, ret); + return ret; + } + } + /* * Detect accessory after completing the initialization of platform * @@ -763,7 +766,6 @@ static int max14577_muic_probe(struct platform_device *pdev) * After completing the booting of platform, the extcon provider * driver should notify cable state to upper layer. */ - INIT_DELAYED_WORK(&info->wq_detcable, max14577_muic_detect_cable_wq); queue_delayed_work(system_power_efficient_wq, &info->wq_detcable, delay_jiffies); -- 2.50.1.windows.1