* [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
0 siblings, 1 reply; 2+ 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] 2+ messages in thread
* Re: [PATCH v1] rust: debugfs: Use kernel Atomic type in docs example
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
0 siblings, 0 replies; 2+ messages in thread
From: Boqun Feng @ 2025-12-03 1:36 UTC (permalink / raw)
To: FUJITA Tomonori
Cc: dakr, gregkh, ojeda, rafael, a.hindborg, aliceryhl, bjorn3_gh,
gary, lossin, rust-for-linux, tmgross
On Wed, Dec 03, 2025 at 09:04:11AM +0900, FUJITA Tomonori wrote:
> 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>
Regards,
Boqun
> ---
> 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 [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-03 1:36 UTC | newest]
Thread overview: 2+ 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).