mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
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>
This commit is contained in:
committed by
Danilo Krummrich
parent
61f5ec54c8
commit
7449057051
@@ -207,20 +207,25 @@ impl Dir {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use core::sync::atomic::{AtomicU32, Ordering};
|
||||
/// # use kernel::debugfs::Dir;
|
||||
/// # use kernel::prelude::*;
|
||||
/// # use kernel::{
|
||||
/// # debugfs::Dir,
|
||||
/// # prelude::*,
|
||||
/// # sync::atomic::{
|
||||
/// # Atomic,
|
||||
/// # Relaxed,
|
||||
/// # },
|
||||
/// # };
|
||||
/// # let dir = Dir::new(c"foo");
|
||||
/// let file = KBox::pin_init(
|
||||
/// dir.read_callback_file(c"bar",
|
||||
/// AtomicU32::new(3),
|
||||
/// Atomic::<u32>::new(3),
|
||||
/// &|val, f| {
|
||||
/// let out = val.load(Ordering::Relaxed);
|
||||
/// let out = val.load(Relaxed);
|
||||
/// writeln!(f, "{out:#010x}")
|
||||
/// }),
|
||||
/// GFP_KERNEL)?;
|
||||
/// // Reading "foo/bar" will show "0x00000003".
|
||||
/// file.store(10, Ordering::Relaxed);
|
||||
/// file.store(10, Relaxed);
|
||||
/// // Reading "foo/bar" will now show "0x0000000a".
|
||||
/// # Ok::<(), Error>(())
|
||||
/// ```
|
||||
|
||||
Reference in New Issue
Block a user