Skip to contentSkip to conversation

i2c: core: document preference for i2c_get_adapter_by_fwnode()

PATCH In review Johan Hovold 3 participants 5 messages Jul 16 – Oct 10

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: core: document preference for i2c_get_adapter_by_fwnode()

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().

---
 drivers/i2c/i2c-core-base.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/i2c/i2c-core-base.c +3 -0
index 3ec04787a737..dd4a813d4360 100644
@@ -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)
 {
Signature · 1 line
2.54.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · 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.

Quoted 4 lines

Note that by implication of_get_i2c_adapter_by_node() is also generally preferred over of_find_i2c_adapter_by_node().

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.

#2 lore raw
Quoted 13 lines · Wolfram Sang
Quoted 12 lines · 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().

Quoted 6 lines
Quoted 1 line

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.

Can this one be picked up now?

Johan

#3 lore raw
In reply to Wolfram Sang
Quoted 10 lines · Wolfram Sang
Quoted 9 lines · 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.

Quoted 6 lines
Quoted 4 lines

Note that by implication of_get_i2c_adapter_by_node() is also generally preferred over of_find_i2c_adapter_by_node().

Andi, can we have that in 7.4 pretty please?

maintainer
#4 lore raw

Hi Johan and Wolfram,

Quoted 11 lines · Wolfram Sang
Quoted 10 lines · Wolfram Sang
Quoted 9 lines · 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.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Note that by implication of_get_i2c_adapter_by_node() is also generally preferred over of_find_i2c_adapter_by_node().

Andi, can we have that in 7.4 pretty please?

I was just pushing this and thanks for pinging me here last night.

Now it's in i2c/i2c.

Thanks,
Andi