Re: [PATCH v6 2/3] rust: i2c: Add basic I2C driver abstractions
From: Igor Korotin
Date: Tue Oct 28 2025 - 16:00:40 EST
Hello Danilo
On 10/27/2025 10:00 PM, Danilo Krummrich wrote:
In fact, quite some C drivers are already doing exactly this by hand. For
instance, see [3]. Four lines after [3], raa215300_rtc_unregister_device() is
registered with devm_add_action_or_reset(), which calls i2c_unregister_device().
Now that you’ve mentioned the parent device, I finally understand what you mean.
Originally, I started my Rust-for-Linux journey with the goal of rewriting one of
our platform drivers that has I2C children — and yes, it has a root platform_device.
For now, I’ve put that rewrite on hold and focused on the I2C part instead, which
is why I was thinking from the perspective of rust_driver_i2c.rs: it’s a purely
artificial sample driver that creates an I2C client for a non-existent physical
device using an I2C adapter. That’s why the puzzle didn’t fit together for me earlier.
Having that said, I'm a bit curious now: What is your use-case for
i2c:Registration?
As for my view of i2c::Registration, I see it as a safe wrapper around i2c_new_client_device that holds a pointer to the newly created I2C client and releases it automatically when dropped.
Thanks for the explanation, I'll drop a new version when ready
Best Regards
Igor