From: Jiawen Liu <1298662399@qq.com>
To: Andi Shyti <andi.shyti@kernel.org>,
Florian Fainelli <florian.fainelli@broadcom.com>,
Ray Jui <rjui@broadcom.com>,
Scott Branden <sbranden@broadcom.com>
Cc: Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>,
linux-i2c@vger.kernel.org, linux-rpi-kernel@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] i2c: bcm2835: remove clients before releasing resources
Date: Sun, 29 Nov 2026 16:29:28 +0400 [thread overview]
Message-ID: <tencent_552045D590B2BAEB4E668085BFBF950EF508@qq.com> (raw)
bcm2835_i2c_remove() releases the exclusive clock-rate reservation,
disables the bus clock, and frees the transfer IRQ before removing the
adapter. Adapter deletion synchronously invokes bound client remove
callbacks, and those callbacks may issue I2C transfers. For example,
ina209 restores its configuration and calibration during removal.
The transfer path waits for completion signaled by the IRQ handler that
has already been freed, so cleanup times out and may access the controller
with its bus clock disabled. Remove the adapter first, then release the
resources after all clients have gone away.
Fixes: f3b54b9a066e ("i2c: add bcm2835 driver")
Signed-off-by: Jiawen Liu <1298662399@qq.com>
---
drivers/i2c/busses/i2c-bcm2835.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
index 0fea44d4df6e8..a9067390c1f73 100644
--- a/drivers/i2c/busses/i2c-bcm2835.c
+++ b/drivers/i2c/busses/i2c-bcm2835.c
@@ -506,11 +506,12 @@ static void bcm2835_i2c_remove(struct platform_device *pdev)
{
struct bcm2835_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
+ i2c_del_adapter(&i2c_dev->adapter);
+
clk_rate_exclusive_put(i2c_dev->bus_clk);
clk_disable_unprepare(i2c_dev->bus_clk);
free_irq(i2c_dev->irq, i2c_dev);
- i2c_del_adapter(&i2c_dev->adapter);
}
static const struct of_device_id bcm2835_i2c_of_match[] = {
--
2.34.1
reply other threads:[~2026-11-29 14:14 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=tencent_552045D590B2BAEB4E668085BFBF950EF508@qq.com \
--to=1298662399@qq.com \
--cc=andi.shyti@kernel.org \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=florian.fainelli@broadcom.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=rjui@broadcom.com \
--cc=sbranden@broadcom.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®