* [PATCH] rust: cpumask: rename CpumaskVar::as[_mut]_ref to from_raw[_mut]
@ 2025-08-13 7:54 Alice Ryhl
2025-08-13 12:55 ` Benno Lossin
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alice Ryhl @ 2025-08-13 7:54 UTC (permalink / raw)
To: Viresh Kumar, Yury Norov, Rafael J. Wysocki
Cc: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich,
linux-pm, rust-for-linux, linux-kernel, Alice Ryhl
The prefix as_* shouldn't be used for constructors. For further
motivation, see commit 2f5606afa4c2 ("device: rust: rename
Device::as_ref() to Device::from_raw()").
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
rust/kernel/cpufreq.rs | 2 +-
rust/kernel/cpumask.rs | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/rust/kernel/cpufreq.rs b/rust/kernel/cpufreq.rs
index afc15e72a7c37ac781f25a8a6edd804fa4c9658a..eea57ba95f241dc06218e2d65a0986a1f9c1415c 100644
--- a/rust/kernel/cpufreq.rs
+++ b/rust/kernel/cpufreq.rs
@@ -543,7 +543,7 @@ pub fn register_em_opp(&mut self) {
pub fn cpus(&mut self) -> &mut cpumask::Cpumask {
// SAFETY: The pointer to `cpus` is valid for writing and remains valid for the lifetime of
// the returned reference.
- unsafe { cpumask::CpumaskVar::as_mut_ref(&mut self.as_mut_ref().cpus) }
+ unsafe { cpumask::CpumaskVar::from_raw_mut(&mut self.as_mut_ref().cpus) }
}
/// Sets clock for the [`Policy`].
diff --git a/rust/kernel/cpumask.rs b/rust/kernel/cpumask.rs
index 3fcbff4386705490b73360e3108fa447e63b7b34..e311ab9038dfdac01cdbfe5a7303caf5922813fd 100644
--- a/rust/kernel/cpumask.rs
+++ b/rust/kernel/cpumask.rs
@@ -270,7 +270,7 @@ pub unsafe fn new(_flags: Flags) -> Result<Self, AllocError> {
///
/// 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_var_t) -> &'a mut Self {
+ pub unsafe fn from_raw_mut<'a>(ptr: *mut bindings::cpumask_var_t) -> &'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
@@ -284,7 +284,7 @@ pub unsafe fn as_mut_ref<'a>(ptr: *mut bindings::cpumask_var_t) -> &'a mut Self
///
/// 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_var_t) -> &'a Self {
+ pub unsafe fn from_raw<'a>(ptr: *const bindings::cpumask_var_t) -> &'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
---
base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
change-id: 20250813-cpumask-asref-1054bd96742d
Best regards,
--
Alice Ryhl <aliceryhl@google.com>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] rust: cpumask: rename CpumaskVar::as[_mut]_ref to from_raw[_mut]
2025-08-13 7:54 [PATCH] rust: cpumask: rename CpumaskVar::as[_mut]_ref to from_raw[_mut] Alice Ryhl
@ 2025-08-13 12:55 ` Benno Lossin
2025-08-13 12:59 ` Yury Norov
2025-08-14 4:13 ` Viresh Kumar
2 siblings, 0 replies; 4+ messages in thread
From: Benno Lossin @ 2025-08-13 12:55 UTC (permalink / raw)
To: Alice Ryhl, Viresh Kumar, Yury Norov, Rafael J. Wysocki
Cc: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Andreas Hindborg, Trevor Gross, Danilo Krummrich, linux-pm,
rust-for-linux, linux-kernel
On Wed Aug 13, 2025 at 9:54 AM CEST, Alice Ryhl wrote:
> The prefix as_* shouldn't be used for constructors. For further
> motivation, see commit 2f5606afa4c2 ("device: rust: rename
> Device::as_ref() to Device::from_raw()").
>
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
---
Cheers,
Benno
> ---
> rust/kernel/cpufreq.rs | 2 +-
> rust/kernel/cpumask.rs | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rust: cpumask: rename CpumaskVar::as[_mut]_ref to from_raw[_mut]
2025-08-13 7:54 [PATCH] rust: cpumask: rename CpumaskVar::as[_mut]_ref to from_raw[_mut] Alice Ryhl
2025-08-13 12:55 ` Benno Lossin
@ 2025-08-13 12:59 ` Yury Norov
2025-08-14 4:13 ` Viresh Kumar
2 siblings, 0 replies; 4+ messages in thread
From: Yury Norov @ 2025-08-13 12:59 UTC (permalink / raw)
To: Alice Ryhl
Cc: Viresh Kumar, Rafael J. Wysocki, Miguel Ojeda, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, linux-pm, rust-for-linux,
linux-kernel
On Wed, Aug 13, 2025 at 07:54:31AM +0000, Alice Ryhl wrote:
> The prefix as_* shouldn't be used for constructors. For further
> motivation, see commit 2f5606afa4c2 ("device: rust: rename
> Device::as_ref() to Device::from_raw()").
>
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Would be nice to describe this rule in Documentation, but anyways:
Reviewed-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
> ---
> rust/kernel/cpufreq.rs | 2 +-
> rust/kernel/cpumask.rs | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/rust/kernel/cpufreq.rs b/rust/kernel/cpufreq.rs
> index afc15e72a7c37ac781f25a8a6edd804fa4c9658a..eea57ba95f241dc06218e2d65a0986a1f9c1415c 100644
> --- a/rust/kernel/cpufreq.rs
> +++ b/rust/kernel/cpufreq.rs
> @@ -543,7 +543,7 @@ pub fn register_em_opp(&mut self) {
> pub fn cpus(&mut self) -> &mut cpumask::Cpumask {
> // SAFETY: The pointer to `cpus` is valid for writing and remains valid for the lifetime of
> // the returned reference.
> - unsafe { cpumask::CpumaskVar::as_mut_ref(&mut self.as_mut_ref().cpus) }
> + unsafe { cpumask::CpumaskVar::from_raw_mut(&mut self.as_mut_ref().cpus) }
> }
>
> /// Sets clock for the [`Policy`].
> diff --git a/rust/kernel/cpumask.rs b/rust/kernel/cpumask.rs
> index 3fcbff4386705490b73360e3108fa447e63b7b34..e311ab9038dfdac01cdbfe5a7303caf5922813fd 100644
> --- a/rust/kernel/cpumask.rs
> +++ b/rust/kernel/cpumask.rs
> @@ -270,7 +270,7 @@ pub unsafe fn new(_flags: Flags) -> Result<Self, AllocError> {
> ///
> /// 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_var_t) -> &'a mut Self {
> + pub unsafe fn from_raw_mut<'a>(ptr: *mut bindings::cpumask_var_t) -> &'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
> @@ -284,7 +284,7 @@ pub unsafe fn as_mut_ref<'a>(ptr: *mut bindings::cpumask_var_t) -> &'a mut Self
> ///
> /// 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_var_t) -> &'a Self {
> + pub unsafe fn from_raw<'a>(ptr: *const bindings::cpumask_var_t) -> &'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
>
> ---
> base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
> change-id: 20250813-cpumask-asref-1054bd96742d
>
> Best regards,
> --
> Alice Ryhl <aliceryhl@google.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rust: cpumask: rename CpumaskVar::as[_mut]_ref to from_raw[_mut]
2025-08-13 7:54 [PATCH] rust: cpumask: rename CpumaskVar::as[_mut]_ref to from_raw[_mut] Alice Ryhl
2025-08-13 12:55 ` Benno Lossin
2025-08-13 12:59 ` Yury Norov
@ 2025-08-14 4:13 ` Viresh Kumar
2 siblings, 0 replies; 4+ messages in thread
From: Viresh Kumar @ 2025-08-14 4:13 UTC (permalink / raw)
To: Alice Ryhl
Cc: Yury Norov, Rafael J. Wysocki, Miguel Ojeda, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, linux-pm, rust-for-linux,
linux-kernel
On 13-08-25, 07:54, Alice Ryhl wrote:
> The prefix as_* shouldn't be used for constructors. For further
> motivation, see commit 2f5606afa4c2 ("device: rust: rename
> Device::as_ref() to Device::from_raw()").
>
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
> ---
> rust/kernel/cpufreq.rs | 2 +-
> rust/kernel/cpumask.rs | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
Applied. Thanks.
--
viresh
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-08-14 4:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-13 7:54 [PATCH] rust: cpumask: rename CpumaskVar::as[_mut]_ref to from_raw[_mut] Alice Ryhl
2025-08-13 12:55 ` Benno Lossin
2025-08-13 12:59 ` Yury Norov
2025-08-14 4:13 ` Viresh Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).