Re: [PATCH v20 5/8] rust: rename `AlwaysRefCounted` to `RefCounted`.
From: Uwe Kleine-König
Date: Mon Aug 24 2026 - 08:30:14 EST
Hello,
On Mon, Aug 24, 2026 at 01:17:57PM +0200, Andreas Hindborg wrote:
> diff --git a/rust/kernel/pwm.rs b/rust/kernel/pwm.rs
> index 6c9d667009ef7..2d1cd74dd98e1 100644
> --- a/rust/kernel/pwm.rs
> +++ b/rust/kernel/pwm.rs
> @@ -13,7 +13,11 @@
> devres,
> error::{self, to_result},
> prelude::*,
> - sync::aref::{ARef, AlwaysRefCounted},
> + sync::aref::{
> + ARef,
> + AlwaysRefCounted,
> + RefCounted, //
> + },
> types::Opaque, //
> };
> use core::{
> @@ -629,7 +633,7 @@ pub fn new<'a>(
> }
>
> // SAFETY: Implements refcounting for `Chip` using the embedded `struct device`.
> -unsafe impl<T: PwmOps> AlwaysRefCounted for Chip<T> {
> +unsafe impl<T: PwmOps> RefCounted for Chip<T> {
> #[inline]
> fn inc_ref(&self) {
> // SAFETY: `self.0.get()` points to a valid `pwm_chip` because `self` exists.
> @@ -647,6 +651,10 @@ unsafe fn dec_ref(obj: NonNull<Chip<T>>) {
> }
> }
>
> +// SAFETY: We do not implement `Ownable`, thus it is okay to obtain an `ARef<Chip<T>>` from a
> +// `&Chip<T>`.
> +unsafe impl<T: PwmOps> AlwaysRefCounted for Chip<T> {}
> +
> // SAFETY: `Chip` is a wrapper around `*mut bindings::pwm_chip`. The underlying C
> // structure's state is managed and synchronized by the kernel's device model
> // and PWM core locking mechanisms. Therefore, it is safe to move the `Chip`
I don't understand that, but if this is considered ok by the Rust folks,
I'm fine with merging it via their tree.
Acked-by: Uwe Kleine-König <ukleinek@xxxxxxxxxx> # for pwm.rs
Best regards
Uwe
Attachment:
signature.asc
Description: PGP signature