Re: [PATCH v6] rust: aref: make `AlwaysRefCounted::inc_ref` an associated function
From: Gary Guo
Date: Mon Jun 29 2026 - 10:38:28 EST
On Sun Jun 28, 2026 at 10:51 AM BST, Trevor Chan wrote:
> `AlwaysRefCounted::inc_ref` is a function that shouldn't be called lightly.
>
> To prevent accidentally calling it, change `inc_ref` to be an associated function.
>
> Modify all `AlwaysRefCounted` implementors to work with this change.
>
> Suggested-by: Benno Lossin <lossin@xxxxxxxxxx>
> Link: https://github.com/Rust-for-Linux/linux/issues/1177
> Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
> Signed-off-by: Trevor Chan <trev@xxxxxxxxxxxx>
Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>
> ---
> Changes in v2:
> - Don't word wrap the patch
> Changes in v3:
> - Make argument name of `Empty::inc_ref` consistent with `Empty::dec_ref`
> Changes in v4:
> - Rebase to new rust-next, change new implementors
> - Reword explanation for change in `AlwaysRefCounted::inc_ref` doc comment
> Changes in v5:
> - Change commit message to be imperative
> Changes in v6:
> - Change all the implementors
> ---
> rust/kernel/auxiliary.rs | 4 ++--
> rust/kernel/block/mq/request.rs | 4 ++--
> rust/kernel/cred.rs | 4 ++--
> rust/kernel/device.rs | 4 ++--
> rust/kernel/device/property.rs | 4 ++--
> rust/kernel/drm/device.rs | 4 ++--
> rust/kernel/drm/gem/mod.rs | 4 ++--
> rust/kernel/drm/gpuvm/mod.rs | 4 ++--
> rust/kernel/drm/gpuvm/vm_bo.rs | 4 ++--
> rust/kernel/fs/file.rs | 8 ++++----
> rust/kernel/i2c.rs | 8 ++++----
> rust/kernel/mm.rs | 8 ++++----
> rust/kernel/mm/mmput_async.rs | 4 ++--
> rust/kernel/opp.rs | 4 ++--
> rust/kernel/pci.rs | 4 ++--
> rust/kernel/pid_namespace.rs | 4 ++--
> rust/kernel/platform.rs | 4 ++--
> rust/kernel/pwm.rs | 2 +-
> rust/kernel/sync/aref.rs | 11 +++++++----
> rust/kernel/task.rs | 4 ++--
> rust/kernel/usb.rs | 8 ++++----
> 21 files changed, 54 insertions(+), 51 deletions(-)