From nobody Sat Jul 25 03:45:58 2026 Received: from mail-m155101.qiye.163.com (mail-m155101.qiye.163.com [101.71.155.101]) (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 8791F25B086 for ; Sun, 19 Jul 2026 14:44:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=101.71.155.101 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784472251; cv=none; b=UNJg5yTpIiNAnlL/WgEr7Q/nC7WVLjNfZC624hPInLu6PqrwsoOpD7vPFAsw6cffUMl42xm5YC1hkvLW90n2r9TMYxT0MP+DqEgyK/1j25op9fUjNwHEQ6UW5V6dxdptC+i9UX2IV6VjJuNqcZ/mFmpnAGEvt4mjEX8aPFvhnMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784472251; c=relaxed/simple; bh=QmwfZx/+HT4a4w9NDb5QwG6xMylq9O1ckv59YzuPbos=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=kN8GndYf4NLGLaw+B5oAKj7RYZbKfMUVQ9hv0XGXk14oOEYUhAVjFeRgUKpgWJYW4U417kAb4QMFGVXIycVi2sJZN8xRTGK8tDUsXfYoJCyFGIQw/85Mb0D9kIaxeHgQ3Wy9P0hfQJi4VQ3d7UWDI822IHS6vGQZHjeg1HfAchY= 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=AQsij5WS; arc=none smtp.client-ip=101.71.155.101 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="AQsij5WS" Received: from LAPTOP-99KJFSET (unknown [222.191.246.242]) by smtp.qiye.163.com (Hmail) with ESMTP id 46bb6c3d2; Sun, 19 Jul 2026 22:44:05 +0800 (GMT+08:00) From: Hongyan Xu To: myungjoo.ham@samsung.com, cw00.choi@samsung.com Cc: linux-kernel@vger.kernel.org, jianhao.xu@seu.edu.cn, getshell@seu.edu.cn Subject: [PATCH] extcon: rt8973a: synchronize work teardown Date: Sun, 19 Jul 2026 22:44:03 +0800 Message-ID: <20260719144403.631-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: quoted-printable X-HM-Tid: 0a9f7ad5951403a1kunmf2146b859556e X-HM-MType: 10 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWRgWCB1ZQUpXWS1ZQUlXWQ8JGhUIEh9ZQVlCQ0pPVh1ISR1LTkJISRgaSlYeHw 5VEwETFhoSFyQUDg9ZV1kYEgtZQVlJSUlVSkJKVUlPTVVJT0lZV1kWGg8SFR0UWUFZT0tIVUpLSU hOQ0NVSktLVUtZBg++ DKIM-Signature: a=rsa-sha256; b=AQsij5WSXvAzl9p5BRu1pOQT/8JpGBXtgXYvFmtRETJvllYQd0MRKbCivrk3++f7sqj2s2DniorpahfhLfnyZC1SlAbB2QbK2dCHGKFmrRpAb+W3bMen3sn0pEgywHyQhgXmElEAQpQVuvA+LqwvB9f9zJYrDBm1tF0rYtQz4Mg=; s=default; c=relaxed/relaxed; d=seu.edu.cn; v=1; bh=rChDk+RzJBOS4qSgjXyQTbSZEXNxKYVmHeLVO+pAJYo=; h=date:mime-version:subject:message-id:from; Content-Type: text/plain; charset="utf-8" Nested IRQ handlers schedule irq_work and probe queues wq_detcable, but remove only deletes the regmap IRQ chip. Either work item can outlive info. Probe failures after the IRQ chip is installed also lack matching chip cleanup. Manage the IRQ chip and both work items with devres, and request nested IRQs after their callback dependencies are initialized. Devres teardown then stops the IRQ producers before cancelling the work. Signed-off-by: Hongyan Xu --- drivers/extcon/extcon-rt8973a.c | 60 ++++++++++++++++----------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers/extcon/extcon-rt8973a.c b/drivers/extcon/extcon-rt8973= a.c index 19bb49f..df8ccdd 100644 --- a/drivers/extcon/extcon-rt8973a.c +++ b/drivers/extcon/extcon-rt8973a.c @@ -6,6 +6,7 @@ * Author: Chanwoo Choi */ =20 +#include #include #include #include @@ -572,8 +573,6 @@ static int rt8973a_muic_i2c_probe(struct i2c_client *i2= c) =20 mutex_init(&info->mutex); =20 - INIT_WORK(&info->irq_work, rt8973a_muic_irq_work); - info->regmap =3D devm_regmap_init_i2c(i2c, &rt8973a_muic_regmap_config); if (IS_ERR(info->regmap)) { ret =3D PTR_ERR(info->regmap); @@ -584,14 +583,41 @@ static int rt8973a_muic_i2c_probe(struct i2c_client *= i2c) =20 /* Support irq domain for RT8973A MUIC device */ irq_flags =3D IRQF_TRIGGER_FALLING | IRQF_ONESHOT | IRQF_SHARED; - ret =3D regmap_add_irq_chip(info->regmap, info->irq, irq_flags, 0, - &rt8973a_muic_irq_chip, &info->irq_data); + ret =3D devm_regmap_add_irq_chip(info->dev, info->regmap, info->irq, + irq_flags, 0, &rt8973a_muic_irq_chip, + &info->irq_data); if (ret !=3D 0) { dev_err(info->dev, "failed to add irq_chip (irq:%d, err:%d)\n", info->irq, ret); return ret; } =20 + /* Allocate extcon device */ + info->edev =3D devm_extcon_dev_allocate(info->dev, rt8973a_extcon_cable); + if (IS_ERR(info->edev)) { + dev_err(info->dev, "failed to allocate memory for extcon\n"); + return -ENOMEM; + } + + /* Register extcon device */ + ret =3D devm_extcon_dev_register(info->dev, info->edev); + if (ret) { + dev_err(info->dev, "failed to register extcon device\n"); + return ret; + } + + ret =3D devm_work_autocancel(info->dev, &info->irq_work, + rt8973a_muic_irq_work); + if (ret) + return ret; + ret =3D devm_delayed_work_autocancel(info->dev, &info->wq_detcable, + rt8973a_muic_detect_cable_wq); + if (ret) + return ret; + + /* Initialize RT8973A device and print vendor id and version id */ + rt8973a_init_dev_type(info); + for (i =3D 0; i < info->num_muic_irqs; i++) { struct muic_irq *muic_irq =3D &info->muic_irqs[i]; int virq =3D 0; @@ -613,20 +639,6 @@ static int rt8973a_muic_i2c_probe(struct i2c_client *i= 2c) } } =20 - /* Allocate extcon device */ - info->edev =3D devm_extcon_dev_allocate(info->dev, rt8973a_extcon_cable); - if (IS_ERR(info->edev)) { - dev_err(info->dev, "failed to allocate memory for extcon\n"); - return -ENOMEM; - } - - /* Register extcon device */ - ret =3D devm_extcon_dev_register(info->dev, info->edev); - if (ret) { - dev_err(info->dev, "failed to register extcon device\n"); - return ret; - } - /* * Detect accessory after completing the initialization of platform * @@ -635,23 +647,12 @@ static int rt8973a_muic_i2c_probe(struct i2c_client *= i2c) * After completing the booting of platform, the extcon provider * driver should notify cable state to upper layer. */ - INIT_DELAYED_WORK(&info->wq_detcable, rt8973a_muic_detect_cable_wq); queue_delayed_work(system_power_efficient_wq, &info->wq_detcable, msecs_to_jiffies(DELAY_MS_DEFAULT)); =20 - /* Initialize RT8973A device and print vendor id and version id */ - rt8973a_init_dev_type(info); - return 0; } =20 -static void rt8973a_muic_i2c_remove(struct i2c_client *i2c) -{ - struct rt8973a_muic_info *info =3D i2c_get_clientdata(i2c); - - regmap_del_irq_chip(info->irq, info->irq_data); -} - static const struct of_device_id rt8973a_dt_match[] =3D { { .compatible =3D "richtek,rt8973a-muic" }, { }, @@ -696,7 +697,6 @@ static struct i2c_driver rt8973a_muic_i2c_driver =3D { .of_match_table =3D rt8973a_dt_match, }, .probe =3D rt8973a_muic_i2c_probe, - .remove =3D rt8973a_muic_i2c_remove, .id_table =3D rt8973a_i2c_id, }; =20 --=20 2.50.1.windows.1