From: Alice Ryhl <aliceryhl@google.com>
To: yilin <1479826151@qq.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>,
Miguel Ojeda <ojeda@kernel.org>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] rust: cpumask: rename methods of Cpumask for clarity and consistency
Date: Wed, 17 Dec 2025 20:35:15 +0000 [thread overview]
Message-ID: <aUMUA_JWalyGQdAx@google.com> (raw)
In-Reply-To: <tencent_5524A2A07DE84AF0D8E4B9B21199603AE905@qq.com>
On Thu, Dec 11, 2025 at 11:17:59PM +0800, yilin wrote:
> Rename `as_ref` and `as_mut_ref` to `from_raw` and `from_raw_mut` to
> align with the established naming convention for constructing types
> from raw pointers in the kernel's Rust codebase.
>
> Signed-off-by: yilin <1479826151@qq.com>
You need to use a real identity such as your real name here. Please see:
https://docs.kernel.org/process/submitting-patches.html#reviewer-s-statement-of-oversight
You should probably also split this series up, as the patches are for
unrelated subsystem.s
The change itself looks good:
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
> rust/kernel/cpumask.rs | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/rust/kernel/cpumask.rs b/rust/kernel/cpumask.rs
> index c1d17826a..44bb36636 100644
> --- a/rust/kernel/cpumask.rs
> +++ b/rust/kernel/cpumask.rs
> @@ -39,7 +39,7 @@
> /// fn set_clear_cpu(ptr: *mut bindings::cpumask, set_cpu: CpuId, clear_cpu: CpuId) {
> /// // SAFETY: The `ptr` is valid for writing and remains valid for the lifetime of the
> /// // returned reference.
> -/// let mask = unsafe { Cpumask::as_mut_ref(ptr) };
> +/// let mask = unsafe { Cpumask::from_raw_mut(ptr) };
> ///
> /// mask.set(set_cpu);
> /// mask.clear(clear_cpu);
> @@ -49,13 +49,13 @@
> pub struct Cpumask(Opaque<bindings::cpumask>);
>
> impl Cpumask {
> - /// Creates a mutable reference to an existing `struct cpumask` pointer.
> + /// Creates a mutable reference from an existing `struct cpumask` pointer.
> ///
> /// # Safety
> ///
> /// The caller must ensure that `ptr` is valid for writing and remains valid for the lifetime
> /// of the returned reference.
> - pub unsafe fn as_mut_ref<'a>(ptr: *mut bindings::cpumask) -> &'a mut Self {
> + pub unsafe fn from_raw_mut<'a>(ptr: *mut bindings::cpumask) -> &'a mut Self {
> // SAFETY: Guaranteed by the safety requirements of the function.
> //
> // INVARIANT: The caller ensures that `ptr` is valid for writing and remains valid for the
> @@ -63,13 +63,13 @@ pub unsafe fn as_mut_ref<'a>(ptr: *mut bindings::cpumask) -> &'a mut Self {
> unsafe { &mut *ptr.cast() }
> }
>
> - /// Creates a reference to an existing `struct cpumask` pointer.
> + /// Creates a reference from an existing `struct cpumask` pointer.
> ///
> /// # Safety
> ///
> /// The caller must ensure that `ptr` is valid for reading and remains valid for the lifetime
> /// of the returned reference.
> - pub unsafe fn as_ref<'a>(ptr: *const bindings::cpumask) -> &'a Self {
> + pub unsafe fn from_raw<'a>(ptr: *const bindings::cpumask) -> &'a Self {
> // SAFETY: Guaranteed by the safety requirements of the function.
> //
> // INVARIANT: The caller ensures that `ptr` is valid for reading and remains valid for the
> --
> 2.34.1
>
prev parent reply other threads:[~2025-12-17 20:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20251211151553.2893838-1-1479826151@qq.com>
2025-12-11 15:17 ` [PATCH 1/3] rust: device_id: replace possible incorrect word in safety document yilin
2025-12-11 15:17 ` [PATCH 2/3] rust: dma: remove incorrect safety documentation yilin
2025-12-11 15:17 ` [PATCH 3/3] rust: cpumask: rename methods of Cpumask for clarity and consistency yilin
2025-12-17 20:35 ` Alice Ryhl [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aUMUA_JWalyGQdAx@google.com \
--to=aliceryhl@google.com \
--cc=1479826151@qq.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.