Re: [PATCH 1/4] rust: i2c: add read and write byte data abstractions
From: Danilo Krummrich
Date: Thu Oct 09 2025 - 08:08:42 EST
On Wed Oct 8, 2025 at 8:10 PM CEST, Markus Probst wrote:
> In addition to the core abstractions, implement
>
> * `i2c::I2cClient::read_byte` - read a byte from the i2c client
> * `i2c::I2cClient::write_byte` - write a byte to the i2c client
>
> * `i2c::I2cClient::read_byte_data` - read byte data from the i2c client
> * `i2c::I2cClient::write_byte_data` - write byte data to the i2c client
>
> * `i2c::I2cClient::read_word_data` - read word data from the i2c client
> * `i2c::I2cClient::write_word_data` - write word data to the i2c client
I don't think those should be implemented to be used by drivers directly.
Instead we should generalize the Io type [1] and allow for arbitrary backends,
such that we can use the register!() macro [2] to define register types for I2C
devices.
Ideally, an I2C / SMBus backend should use regmap right away.
The register!() macro is currently moved into the generic infrastructure [3].
[1] https://rust.docs.kernel.org/kernel/io/struct.Io.html
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/nova-core/regs/macros.rs
[3] https://lore.kernel.org/all/20251003154748.1687160-1-joelagnelf@xxxxxxxxxx/