Re: [PATCH v20 5/8] rust: rename `AlwaysRefCounted` to `RefCounted`.
Uwe Kleine-König <[email protected]>
| Newsgroups | org.kernel.vger.linux-pwm,dev.linux.lists.driver-core,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-block,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pci,org.kernel.vger.linux-pm,org.kernel.vger.linux-security-module,org.kernel.vger.linux-usb,org.kernel.vger.rust-for-linux,org.kvack.linux-mm |
|---|---|
| Message-ID | <aow36NjRc5Ig0hG8@monoceros> |
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 <[email protected]> # for pwm.rs
Best regards
Uwe
signature.asc
(application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmqMOGEACgkQj4D7WH0S /k7Eqwf+MmntLyABjsJ6u3n0tfvFXtT43FkhKWBYTvfrSkkGSwvZSD/ZY5rm4TJa bXNvGj/meY+tjoiL+lqEl91gKDUE91djmvVcfXDoceliQzIKh2cKRqYubSng7etR 4cjqGN+2sGoPMqw/DE4AHSt6FjN7PW9atWXCHSqgj1X59q+Il9zzPvJoUf5LoJGl M03B0IF/eZP8vEHvwBR+bKlVqdJnU8LD7vn7fYKS9w8EcXVmRNet0ARjs8XnIUhd mRyFbmkqewycYxQaQdFwYsqkvc+ZdQfjXofOkRIorYXk2OXiZy3oqy94wwwiGntm xaLKESdeyy1mp9Q0CzYXHqcQr8nU5Q== =h9TM -----END PGP SIGNATURE-----