public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] rust: debugfs: Use kernel Atomic type in docs example
@ 2025-12-03  0:04 FUJITA Tomonori
  2025-12-03  1:36 ` Boqun Feng
  2026-01-19 14:07 ` Danilo Krummrich
  0 siblings, 2 replies; 5+ messages in thread
From: FUJITA Tomonori @ 2025-12-03  0:04 UTC (permalink / raw)
  To: dakr, gregkh, ojeda, rafael
  Cc: a.hindborg, aliceryhl, bjorn3_gh, boqun.feng, gary, lossin,
	rust-for-linux, tmgross

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>
---
 rust/kernel/debugfs.rs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/rust/kernel/debugfs.rs b/rust/kernel/debugfs.rs
index 381c23b3dd83..9236866d6285 100644
--- a/rust/kernel/debugfs.rs
+++ b/rust/kernel/debugfs.rs
@@ -158,21 +158,21 @@ pub fn read_only_file<'a, T, E: 'a>(
     /// # Examples
     ///
     /// ```
-    /// # use core::sync::atomic::{AtomicU32, Ordering};
+    /// # use kernel::sync::atomic::{Atomic, Relaxed};
     /// # use kernel::c_str;
     /// # use kernel::debugfs::Dir;
     /// # use kernel::prelude::*;
     /// # let dir = Dir::new(c_str!("foo"));
     /// let file = KBox::pin_init(
     ///     dir.read_callback_file(c_str!("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>(())
     /// ```

base-commit: d61f1cc5db799f4e44a63418b2dc19396787427b
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-01-19 14:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-03  0:04 [PATCH v1] rust: debugfs: Use kernel Atomic type in docs example FUJITA Tomonori
2025-12-03  1:36 ` Boqun Feng
2026-01-19 13:49   ` FUJITA Tomonori
2026-01-19 13:51     ` Danilo Krummrich
2026-01-19 14:07 ` Danilo Krummrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox