* [PATCH 1/3] rust: device_id: replace possible incorrect word in safety document
[not found] <20251211151553.2893838-1-1479826151@qq.com>
@ 2025-12-11 15:17 ` 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
2 siblings, 0 replies; 3+ messages in thread
From: yilin @ 2025-12-11 15:17 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J . Wysocki, Danilo Krummrich,
Miguel Ojeda
Cc: rust-for-linux, linux-kernel, yilin
The safety documentation incorrectly refers to `RawDeviceId` when
transmuting to `RawType`. This fixes the documentation to correctly
indicate that implementers must ensure layout compatibility with
`RawType`, not `RawDeviceId`.
Signed-off-by: yilin <1479826151@qq.com>
---
rust/kernel/device_id.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rust/kernel/device_id.rs b/rust/kernel/device_id.rs
index 62c42da12..8e9721446 100644
--- a/rust/kernel/device_id.rs
+++ b/rust/kernel/device_id.rs
@@ -15,7 +15,7 @@
/// # Safety
///
/// Implementers must ensure that `Self` is layout-compatible with [`RawDeviceId::RawType`];
-/// i.e. it's safe to transmute to `RawDeviceId`.
+/// i.e. it's safe to transmute to `RawType`.
///
/// This requirement is needed so `IdArray::new` can convert `Self` to `RawType` when building
/// the ID table.
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/3] rust: dma: remove incorrect safety documentation
[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 ` yilin
2025-12-11 15:17 ` [PATCH 3/3] rust: cpumask: rename methods of Cpumask for clarity and consistency yilin
2 siblings, 0 replies; 3+ messages in thread
From: yilin @ 2025-12-11 15:17 UTC (permalink / raw)
To: Danilo Krummrich, Miguel Ojeda; +Cc: rust-for-linux, linux-kernel, yilin
Removes a safety requirement that incorrectly states callers must
ensure the device does not access memory while the returned slice
is live, as this method doesn't return a slice.
Signed-off-by: yilin <1479826151@qq.com>
---
rust/kernel/dma.rs | 2 --
1 file changed, 2 deletions(-)
diff --git a/rust/kernel/dma.rs b/rust/kernel/dma.rs
index 84d3c6726..2ac107d8f 100644
--- a/rust/kernel/dma.rs
+++ b/rust/kernel/dma.rs
@@ -532,8 +532,6 @@ pub unsafe fn as_slice_mut(&mut self, offset: usize, count: usize) -> Result<&mu
///
/// # Safety
///
- /// * Callers must ensure that the device does not read/write to/from memory while the returned
- /// slice is live.
/// * Callers must ensure that this call does not race with a read or write to the same region
/// that overlaps with this write.
///
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 3/3] rust: cpumask: rename methods of Cpumask for clarity and consistency
[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 ` yilin
2 siblings, 0 replies; 3+ messages in thread
From: yilin @ 2025-12-11 15:17 UTC (permalink / raw)
To: Viresh Kumar, Miguel Ojeda; +Cc: rust-for-linux, linux-kernel, yilin
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>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-12-11 15:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[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
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).