From nobody Sat Jul 25 03:46:05 2026 Received: from mail-m49198.qiye.163.com (mail-m49198.qiye.163.com [45.254.49.198]) (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 19CDC39D6C8 for ; Sun, 19 Jul 2026 14:44:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784472265; cv=none; b=UFUrHvmMq2RPr7oVEoqqGqN1EpXA9S7AJM6D+sJzByOraeR1PPOHSIP1aNHg6gRN026ywxYjEKd7ENCCLDKoUXU4McLDaG9FNdqawsPYfPrWsxxaTb2lrbblWWNDysEfU3JY60gb1NF+iPQI+S4D9EkIOa7XC6kZrdPhLB9Hq/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784472265; c=relaxed/simple; bh=JlFp1xE3AX+DOctiS/hXPu2qoc0ywJjIbDvZOalj4Vk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=grIdnSvzUeYMaTGb6hR0KQjUU93NgRJCn/Y2K0KrojyH5/vEoNw32xSToKT4Ffg3NYKdI18efzX7y4BG5KQ0DjLogLaI62YAyKNorJzhL82nQ042O0YrrIhqcA5M1JtM9JwJK0eIs1/rMj1uuT9QNcpDr+Ba6OybJW/23dlTvtM= 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=nrPPoCGj; arc=none smtp.client-ip=45.254.49.198 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="nrPPoCGj" Received: from LAPTOP-99KJFSET (unknown [222.191.246.242]) by smtp.qiye.163.com (Hmail) with ESMTP id 46bb6c3d4; Sun, 19 Jul 2026 22:44:17 +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: sm5502: synchronize work teardown Date: Sun, 19 Jul 2026 22:44:15 +0800 Message-ID: <20260719144415.636-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: 0a9f7ad5c2dd03a1kunm6a49a32c95583 X-HM-MType: 10 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWRgWCB1ZQUpXWS1ZQUlXWQ8JGhUIEh9ZQVlCGR9PVkxCHRlDTB9MQh0eQlYeHw 5VEwETFhoSFyQUDg9ZV1kYEgtZQVlJSUlVSkJKVUlPTVVJT0lZV1kWGg8SFR0UWUFZT0tIVUpLSU hOQ0NVSktLVUtZBg++ DKIM-Signature: a=rsa-sha256; b=nrPPoCGjUR5iF5tQs+nexgdbBJP9Az9NpyvDXuTvmVTS8ySQ4pKNQ0tTlXLz7WCihuiPELg7MxwiH+D9i7+uBQA+U20NM/RQXxm5VS4YtGqEBQVc91VK7LknRFrazRQAW/ZLCfm5BPadg8L137iKESk9NaiMqgUZ5gJYUcOsblM=; s=default; c=relaxed/relaxed; d=seu.edu.cn; v=1; bh=UHCOk66jVrciDObF3Z78yn35J80Vox37+Fho5AVIAlw=; 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. Neither work item is cancelled when probe unwinds or the I2C device is detached, so devres can release info while a callback is pending. Register automatic work cancellation before requesting the nested IRQs. Reverse-order devres teardown then frees all IRQ producers before cancelling the work and releasing its dependencies. Signed-off-by: Hongyan Xu --- drivers/extcon/extcon-sm5502.c | 45 ++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/drivers/extcon/extcon-sm5502.c b/drivers/extcon/extcon-sm5502.c index c8c4b9e..50e6783 100644 --- a/drivers/extcon/extcon-sm5502.c +++ b/drivers/extcon/extcon-sm5502.c @@ -6,6 +6,7 @@ * Author: Chanwoo Choi */ =20 +#include #include #include #include @@ -699,8 +700,6 @@ static int sm5022_muic_i2c_probe(struct i2c_client *i2c) =20 mutex_init(&info->mutex); =20 - INIT_WORK(&info->irq_work, sm5502_muic_irq_work); - info->regmap =3D devm_regmap_init_i2c(i2c, &sm5502_muic_regmap_config); if (IS_ERR(info->regmap)) { ret =3D PTR_ERR(info->regmap); @@ -720,6 +719,29 @@ static int sm5022_muic_i2c_probe(struct i2c_client *i2= c) return ret; } =20 + /* Allocate extcon device */ + info->edev =3D devm_extcon_dev_allocate(info->dev, sm5502_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, + sm5502_muic_irq_work); + if (ret) + return ret; + ret =3D devm_delayed_work_autocancel(info->dev, &info->wq_detcable, + sm5502_muic_detect_cable_wq); + if (ret) + return ret; + for (i =3D 0; i < info->type->num_muic_irqs; i++) { struct muic_irq *muic_irq =3D &info->type->muic_irqs[i]; int virq =3D 0; @@ -741,19 +763,8 @@ static int sm5022_muic_i2c_probe(struct i2c_client *i2= c) } } =20 - /* Allocate extcon device */ - info->edev =3D devm_extcon_dev_allocate(info->dev, sm5502_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; - } + /* Initialize SM5502 device and print vendor id and version id */ + sm5502_init_dev_type(info); =20 /* * Detect accessory after completing the initialization of platform @@ -763,13 +774,9 @@ static int sm5022_muic_i2c_probe(struct i2c_client *i2= c) * After completing the booting of platform, the extcon provider * driver should notify cable state to upper layer. */ - INIT_DELAYED_WORK(&info->wq_detcable, sm5502_muic_detect_cable_wq); queue_delayed_work(system_power_efficient_wq, &info->wq_detcable, msecs_to_jiffies(DELAY_MS_DEFAULT)); =20 - /* Initialize SM5502 device and print vendor id and version id */ - sm5502_init_dev_type(info); - return 0; } =20 --=20 2.50.1.windows.1