Re: [PATCH 4/5] rust: i2c: add I2C wrappers

From: Danilo Krummrich

Date: Wed Feb 04 2026 - 12:08:39 EST


On Wed Feb 4, 2026 at 5:49 PM CET, Igor Korotin wrote:
> I'm not sure it is appropriate to use IO and register! here. I2C devices
> are different. Not all of them use register like access. For example
> EEPROM I2C devices allow random read/write operations inside their
> address space. After all I2C doesn't implement the same way of accessing
> its memory space as for example PCI devices.

Conceptually, it is not different, it is some device memory connected through
some bus.

Memory mapped I/O allows "random read/write operations" as well, see
memcpy_fromio() and memcpy_toio().

The same thing is true for DMA memory. While it's not owned by the device, it's
still shared with a device.

Gary just started working on a generic IoView<'io, T> type which will serve as a
general abstraction to interact with any kind of memory that is shared between a
device and the CPU [1].

So, for I2C this would mean that if you have register like accesses you can use
the register!() abstractions. If you want random read/write operations, you can
use IoView to copy from / to system memory or even to a user buffer directly.

Of course you can also still use Io::read32() and friends.

[1] https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/Generic.20I.2FO.20backends/with/571786051