Re: [RFC PATCH v3 1/4] i2c: rust: implement kernel::io::Io trait for I2cClient
From: Jonathan Cameron
Date: Tue Jun 02 2026 - 07:59:36 EST
On Tue, 2 Jun 2026 15:11:12 +0700
Muchamad Coirul Anwar <muchamadcoirulanwar@xxxxxxxxx> wrote:
> On Mon, 1 Jun 2026 10:05:00 +0100
> Jonathan Cameron <jic23@xxxxxxxxxx> wrote:
>
> > +CC linux-i2c and Wolfram - make sure to keep them on future versions
> > of this patch.
>
> Noted.
>
> > If this was renamed to make it the rust smbus binding then I wouldn't
> > be as bothered by this. For something claiming to be I2C this is a
> > misleading interface and I am very much against it.
>
> Agreed. I'll rename it to make it clearly SMBus-scoped in v4.
>
> > Understood that there is more to do, but given the regmap already
> > encapsulates the smbus support you have here, I'd be much more in
> > favour of the focus going on getting that done.
> >
> > I would almost suggest not merging a non regmap interface for what you
> > cover here, except we do get annoying corner cases where the device
> > uses a mixture of smbus like commands and non smbus so there probably
> > will need to be support at the i2c / smbus level.
>
> Makes sense. Will defer to Wolfram and the i2c folks on whether this
> should wait for regmap or land as a clearly-scoped SMBus patch.
>
>
> > Is this separating a safety argument from a bug check? If so why
> > not just use the tighter one?
>
> > + fn maxsize(&self) -> usize {
> > + 256
> > + }
>
> The try_read8 here is a general SMBus wrapper, not AS5600-specific.
> The u8 command (register address) applies to any SMBus device, so
> 8-bit is the protocol max. If we tighten below that, it breaks devices
> with registers at 0x80 and above. The 7-bit limit applies to the
> device address, not this command byte.
Ah.. Sorry, I was being stupid and had forgotten the meaning
of the address byte (which device + that magic r/w bit which
is oddly in that byte). I even read wrong section of the smbus
protocol description as it has both read byte and read byte data
only the second of which takes a command byte.
I think I got thrown by the generic naming of try_read8 that
doesn't capture that distinction but given it comes from the trait
I guess we can't do much about that.
Jonathan
>
> Thanks,
> Coirul