Skip to content

i2c: provide and use i2c_adapter_dev()

Bartosz Golaszewski linux-i2c lkml 2 versions – In review

Get series with b4
b4 am 20260223-i2c-adapter-dev-wrapper-v2-0-d02946569773@oss.qualcomm.com change-id 20251222-i2c-adapter-dev-wrapper-c882660190a2

Versions newest first

  1. v2 Latest4 patches 5 repliesIn review
  2. v16 patches 9 repliesSuperseded

Changes in v2 from the cover letter

- drop two patches that can be addressed in a different series
- rebase on top of v7.0-rc1
- collect tags
- Link to v1: https://lore.kernel.org/r/20251223-i2c-adapter-dev-wrapper-v1-0-bcf960a48fa9@oss.qualcomm.com

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4i2c: provide i2c_adapter_dev()include/linux/i2c.h+5 -00 replies
2/4i2c: piix4: use i2c_adapter_dev()drivers/i2c/busses/i2c-piix4.c+3 -30 replies
3/4i2c: amd-asf-plat: use i2c_adapter_dev()drivers/i2c/busses/i2c-amd-asf-plat.c+2 -20 replies
4/4i2c: mv64xxx: use i2c_adapter_dev()drivers/i2c/busses/i2c-mv64xxx.c+2 -23 replies

Reviews trailers per patch

3 of 4 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchJean DelvareShyam Sundar S KGregory CLEMENTAndy Shevchenko
SeriesR-b
1/4
2/4A-b
3/4A-b
4/4R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v2 thread

Cover letter [PATCH v2 0/4] i2c: provide and use i2c_adapter_dev()

It's been another year of discussing the object life-time problems at conferences. I2C is one of the offenders and its problems are more complex than those of some other subsystems. It seems the revocable[1] API may make its way into the kernel this year but even with it in place, I2C won't be able to use it as there's currently nothing to *revoke*. The struct device is embedded within the i2c_adapter struct whose lifetime is tied to the provider device being bound to its driver.

Fixing this won't be fast and easy but nothing's going to happen if we don't start chipping away at it. The ultimate goal in order to be able to use an SRCU-based solution (revocable or otherwise) is to convert the embedded struct device in struct i2c_adapter into an __rcu pointer that can be *revoked*. To that end we need to hide all dereferences of adap->dev in drivers.

Other series address more generic problems - like printk helpers and parent/of_node setting - but there are still some more specific use-cases of drivers dereferencing the internal struct device of i2c_adapters. We need to hide the fact that the device is embedded in i2c_adapter before we can move it out so provide a helper that provides the address of struct device without showing how it's stored and use it in some drivers.

---
Changes in v2:
- drop two patches that can be addressed in a different series
- rebase on top of v7.0-rc1
- collect tags
- Link to v1: https://lore.kernel.org/r/20251223-i2c-adapter-dev-wrapper-v1-0-bcf960a48fa9@oss.qualcomm.com

---
Bartosz Golaszewski (4):
i2c: provide i2c_adapter_dev()
i2c: piix4: use i2c_adapter_dev()
i2c: amd-asf-plat: use i2c_adapter_dev()
i2c: mv64xxx: use i2c_adapter_dev()

 drivers/i2c/busses/i2c-amd-asf-plat.c | 4 ++--
 drivers/i2c/busses/i2c-mv64xxx.c      | 4 ++--
 drivers/i2c/busses/i2c-piix4.c        | 6 +++---
 include/linux/i2c.h                   | 5 +++++
 4 files changed, 12 insertions(+), 7 deletions(-)

---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-adapter-dev-wrapper-c882660190a2

Best regards,

Signature · 1 line
Bartosz Golaszewski <[email protected]>