Re: [PATCH 4/5] rust: i2c: add I2C wrappers
From: Igor Korotin
Date: Wed Feb 04 2026 - 11:56:03 EST
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.
ThanksCheers
- 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@xxxxxxxxxx/
Igor