[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <00b38d6a-a334-4e9b-b8ae-172f3ea16cb1@linux.dev>
Date: Sun, 8 Feb 2026 12:44:53 +0000
From: Igor Korotin <igor.korotin@...ux.dev>
To: Danilo Krummrich <dakr@...nel.org>
Cc: Markus Probst <markus.probst@...teo.de>, igor.korotin.linux@...il.com,
Daniel Almeida <daniel.almeida@...labora.com>,
Miguel Ojeda <ojeda@...nel.org>, Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>, Björn Roy Baron
<bjorn3_gh@...tonmail.com>, Benno Lossin <lossin@...nel.org>,
Andreas Hindborg <a.hindborg@...nel.org>, Alice Ryhl <aliceryhl@...gle.com>,
Trevor Gross <tmgross@...ch.edu>,
Wolfram Sang <wsa+renesas@...g-engineering.com>,
linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org,
linux-i2c@...r.kernel.org
Subject: Re: [PATCH 4/5] rust: i2c: add I2C wrappers
Hello Danilo
On 2/4/2026 4:59 PM, Danilo Krummrich wrote:
> 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
thanks, that makes sense.
I don’t have a strong prior opinion on how this should look yet, so I’m
fine aligning the I2C abstractions with the generic direction you
describe. Using register!() for register-like accesses and IoView for
more general read/write patterns seems reasonable.
At this point I’ll treat this as the intended model and adjust the I2C
side accordingly once IoView is in place and its API settles.
Regards,
Igor
Powered by blists - more mailing lists