* [PATCH] i2c: core: document preference for i2c_get_adapter_by_fwnode()
@ 2026-07-16 13:30 Johan Hovold
2026-08-01 20:57 ` Wolfram Sang
0 siblings, 1 reply; 2+ messages in thread
From: Johan Hovold @ 2026-07-16 13:30 UTC (permalink / raw)
To: Andi Shyti; +Cc: linux-i2c, linux-kernel, Johan Hovold
The i2c subsystem currently blocks during adapter deregistration
whenever there are consumers holding a reference.
Document that i2c_get_adapter_by_fwnode(), which also takes a module
reference, should almost always be preferred over
i2c_find_adapter_by_fwnode() so that an attempt to unload the adapter
module while in use fails gracefully instead of blocking
uninterruptibly.
Note that by implication of_get_i2c_adapter_by_node() is also generally
preferred over of_find_i2c_adapter_by_node().
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/i2c/i2c-core-base.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 3ec04787a737..dd4a813d4360 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1895,6 +1895,9 @@ static int i2c_dev_or_parent_fwnode_match(struct device *dev, const void *data)
* If no adapter can be found, or @fwnode is NULL, this returns NULL.
*
* The user must call put_device(&adapter->dev) once done with the i2c adapter.
+ *
+ * Note that i2c_get_adapter_by_fwnode(), which also takes a module reference,
+ * should almost always be used instead of this one.
*/
struct i2c_adapter *i2c_find_adapter_by_fwnode(struct fwnode_handle *fwnode)
{
--
2.54.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] i2c: core: document preference for i2c_get_adapter_by_fwnode()
2026-07-16 13:30 [PATCH] i2c: core: document preference for i2c_get_adapter_by_fwnode() Johan Hovold
@ 2026-08-01 20:57 ` Wolfram Sang
0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2026-08-01 20:57 UTC (permalink / raw)
To: Johan Hovold; +Cc: Andi Shyti, linux-i2c, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 852 bytes --]
On Thu, Jul 16, 2026 at 03:30:29PM +0200, Johan Hovold wrote:
> The i2c subsystem currently blocks during adapter deregistration
> whenever there are consumers holding a reference.
>
> Document that i2c_get_adapter_by_fwnode(), which also takes a module
> reference, should almost always be preferred over
> i2c_find_adapter_by_fwnode() so that an attempt to unload the adapter
> module while in use fails gracefully instead of blocking
> uninterruptibly.
>
> Note that by implication of_get_i2c_adapter_by_node() is also generally
> preferred over of_find_i2c_adapter_by_node().
>
> Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Andi, I would suggest to apply it to for-current even, because this is
an important doc update, but I'll leave it to you, of course.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-01 20:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-16 13:30 [PATCH] i2c: core: document preference for i2c_get_adapter_by_fwnode() Johan Hovold
2026-08-01 20:57 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox