From: Hongyan Xu <getshell@seu.edu.cn>
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 [thread overview]
Message-ID: <20260719144352.598-1-getshell@seu.edu.cn> (raw)
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 <getshell@seu.edu.cn>
---
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
reply other threads:[~2026-07-19 14:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260719144352.598-1-getshell@seu.edu.cn \
--to=getshell@seu.edu.cn \
--cc=cw00.choi@samsung.com \
--cc=jianhao.xu@seu.edu.cn \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.