Re: [RFC PATCH v2] rust: i2c: Remove use of bindings::i2c_match_id

From: Gary Guo

Date: Tue Nov 17 2026 - 06:37:36 EST


On Wed Nov 11, 2026 at 11:10 PM GMT, Andrew Davis wrote:
> The C function i2c_match_id() is slated for removal, remove use of this
> from Rust I2C by switching to bindings::i2c_get_match_data().
>
> Signed-off-by: Andrew Davis <afd@xxxxxx>
> ---
>
> Well Sashiko suggested I take the easy way and just re-use a different C
> function instead of trying to open-code the loop in Rust. The C function
> implements the same lookup as i2c_id_info did so we can drop that out and
> its i2c_id_table helper. Still would like some help on checking if this
> is actually correct though..

We historically use open-coded matching in Rust as integer indices are used
instead of pointers, but we have cleaned it up since
https://lore.kernel.org/driver-core/20260629-id_info-v2-0-56fccbe9c5ef@xxxxxxxxxxx
So open-coded logic should be all removable now.

Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>

>
> Thanks,
> Andrew
>
> rust/kernel/i2c.rs | 39 +++++++--------------------------------
> 1 file changed, 7 insertions(+), 32 deletions(-)