Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: debugfs: Use kernel Atomic type in docs example

Switch the read_callback_file() documentation example from
core::sync::atomic::AtomicU32 to the kernel's Atomic because Rust
native atomics are not allowed to use in kernel.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://patch.msgid.link/20251203000411.30434-1-fujita.tomonori@gmail.com
[ Use kernel vertical import style. - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

authored by

FUJITA Tomonori and committed by
Danilo Krummrich
74490570 61f5ec54

+11 -6
+11 -6
rust/kernel/debugfs.rs
··· 207 207 /// # Examples 208 208 /// 209 209 /// ``` 210 - /// # use core::sync::atomic::{AtomicU32, Ordering}; 211 - /// # use kernel::debugfs::Dir; 212 - /// # use kernel::prelude::*; 210 + /// # use kernel::{ 211 + /// # debugfs::Dir, 212 + /// # prelude::*, 213 + /// # sync::atomic::{ 214 + /// # Atomic, 215 + /// # Relaxed, 216 + /// # }, 217 + /// # }; 213 218 /// # let dir = Dir::new(c"foo"); 214 219 /// let file = KBox::pin_init( 215 220 /// dir.read_callback_file(c"bar", 216 - /// AtomicU32::new(3), 221 + /// Atomic::<u32>::new(3), 217 222 /// &|val, f| { 218 - /// let out = val.load(Ordering::Relaxed); 223 + /// let out = val.load(Relaxed); 219 224 /// writeln!(f, "{out:#010x}") 220 225 /// }), 221 226 /// GFP_KERNEL)?; 222 227 /// // Reading "foo/bar" will show "0x00000003". 223 - /// file.store(10, Ordering::Relaxed); 228 + /// file.store(10, Relaxed); 224 229 /// // Reading "foo/bar" will now show "0x0000000a". 225 230 /// # Ok::<(), Error>(()) 226 231 /// ```