[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <93559442-38a9-4b6b-9cbb-7bb500ab1738@linux.dev>
Date: Wed, 4 Feb 2026 16:49:41 +0000
From: Igor Korotin <igor.korotin@...ux.dev>
To: Markus Probst <markus.probst@...teo.de>, igor.korotin.linux@...il.com,
Danilo Krummrich <dakr@...nel.org>,
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>
Cc: 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 Markus
On 1/31/2026 2:28 PM, Markus Probst wrote:
> I think I2CClient should implement the IO [1] trait instead, as
> suggested by Danilo [2].
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.
> Also I think it is a little odd that read and write is possible, on
> I2CClient<Normal> and not I2CClient<Bound>. Shouldn't the assigned
> driver have exclusive read and write access to the device?
`Bound` can be safely dereferenced to `Normal`. Since `Normal` represents
the minimal required typestate for device operations, any API that works
with `Normal` automatically works with `Bound` or `Core` as well. Requiring
`Bound` would unnecessarily restrict the API and force duplication or
unsafe casts.
> Thanks
> - Markus Probst
>
> [1]
> https://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git/commit/?h=driver-core-testing&id=121d87b28e1d9061d3aaa156c43a627d3cb5e620
> [2]
> https://lore.kernel.org/rust-for-linux/DDDS2V0V2NVJ.16ZKXCKUA1HUV@kernel.org/
Cheers
Igor
Powered by blists - more mailing lists