Thread (6 messages) flat view 6 messages, 2 authors, 7d ago
COOLING7d

Revision v1 of 2 in this series.

Revisions (2)
  1. v1 current
  2. v2 [diff vs current]

[PATCH 2/3] rust: uaccess: migrate to zerocopy's `Frombytes/IntoBytes`

From: Sagar Taunk <hidden>
Date: 2026-09-06 07:17:15
Also in: lkml
Subsystem: rust, the rest · Maintainers: Miguel Ojeda, Linus Torvalds

Replace explicit imports of `transmute::FromBytes`/`AsBytes` marker
traits with their zerocopy equivalents.

Link: https://github.com/Rust-for-Linux/linux/issues/1241
Signed-off-by: Sagar Taunk <redacted>
---
 rust/kernel/uaccess.rs | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/rust/kernel/uaccess.rs b/rust/kernel/uaccess.rs
index 5f6c4d7a1a51..d93c1a21f324 100644
--- a/rust/kernel/uaccess.rs
+++ b/rust/kernel/uaccess.rs
@@ -13,7 +13,6 @@
     fs::file,
     prelude::*,
     ptr::KnownSize,
-    transmute::{AsBytes, FromBytes},
 };
 use core::mem::{size_of, MaybeUninit};
 
@@ -525,7 +524,7 @@ pub fn write_slice(&mut self, data: &[u8]) -> Result {
     ///     writer.write_dma(alloc, 0, 256)
     /// }
     /// ```
-    pub fn write_dma<T: KnownSize + AsBytes + ?Sized>(
+    pub fn write_dma<T: KnownSize + IntoBytes + ?Sized>(
         &mut self,
         alloc: &Coherent<T>,
         offset: usize,
@@ -599,7 +598,7 @@ pub fn write_slice_file(&mut self, data: &[u8], offset: &mut file::Offset) -> Re
     /// Fails with [`EFAULT`] if the write happens on a bad address, or if the write goes out of
     /// bounds of this [`UserSliceWriter`]. This call may modify the associated userspace slice even
     /// if it returns an error.
-    pub fn write<T: AsBytes>(&mut self, value: &T) -> Result {
+    pub fn write<T: IntoBytes>(&mut self, value: &T) -> Result {
         let len = size_of::<T>();
         if len > self.length {
             return Err(EFAULT);
-- 
2.55.0

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help