Re: [PATCH v2 2/4] rust: i2c: Update ARef and AlwaysRefCounted imports to use sync::aref

Igor Korotin
2026-01-03T20:20:40Z

On 1/2/2026 8:27 PM, Shankari Anand wrote:
> Update call sites in `i2c.rs` to import `ARef` and
> `AlwaysRefCounted` from `sync::aref` instead of `types`.
>
> This aligns with the ongoing effort to move `ARef` and
> `AlwaysRefCounted` to sync.
>
> Suggested-by: Benno Lossin <lossin@kernel.org>
> Link: https://github.com/Rust-for-Linux/linux/issues/1173
> Signed-off-by: Shankari Anand <shankari.ak0208@gmail.com>
> Acked-by: Igor Korotin <igor.korotin.linux@gmail.com>
> ---
> v1 -> v2:
>
> Used the direct module name instead of including the path again,
> re-worded the commit title to rust: i2c: and
> carry-forwarded the Acked-by tag.
>
> Link of v1: https://lore.kernel.org/all/20251123092438.182251-6-shankari.ak0208@gmail.com/
>
> ---
> rust/kernel/i2c.rs | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/rust/kernel/i2c.rs b/rust/kernel/i2c.rs
> index 491e6cc25cf4..9f5f18792916 100644
> --- a/rust/kernel/i2c.rs
> +++ b/rust/kernel/i2c.rs
> @@ -16,10 +16,8 @@
> error::*,
> of,
> prelude::*,
> - types::{
> - AlwaysRefCounted,
> - Opaque, //
> - }, //
> + sync::aref::AlwaysRefCounted,
> + types::Opaque, //
> };
>
> use core::{
> @@ -31,7 +29,7 @@
> }, //
> };
>
> -use kernel::types::ARef;
> +use kernel::sync::aref::ARef;
>
> /// An I2C device id table.
> #[repr(transparent)]
> @@ -407,7 +405,7 @@ pub fn get(index: i32) -> Result<ARef<Self>> {
> kernel::impl_device_context_into_aref!(I2cAdapter);
>
> // SAFETY: Instances of `I2cAdapter` are always reference-counted.
> -unsafe impl crate::types::AlwaysRefCounted for I2cAdapter {
> +unsafe impl AlwaysRefCounted for I2cAdapter {
> fn inc_ref(&self) {
> // SAFETY: The existence of a shared reference guarantees that the refcount is non-zero.
> unsafe { bindings::i2c_get_adapter(self.index()) };
>

Acked-by: Igor Korotin <igor.korotin.linux@gmail.com>

Since I still don’t yet have a public kernel tree, I’d appreciate it if
someone could pick this up through their tree.

Thanks
Igor