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

From: Sagar Taunk

Date: Sun Sep 06 2026 - 06:29:51 EST


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 <sagartaunk@xxxxxxxxx>
---
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