rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boqun Feng <boqun.feng@gmail.com>
To: FUJITA Tomonori <fujita.tomonori@gmail.com>
Cc: dakr@kernel.org, gregkh@linuxfoundation.org, ojeda@kernel.org,
	rafael@kernel.org, a.hindborg@kernel.org, aliceryhl@google.com,
	bjorn3_gh@protonmail.com, gary@garyguo.net, lossin@kernel.org,
	rust-for-linux@vger.kernel.org, tmgross@umich.edu
Subject: Re: [PATCH v1] rust: debugfs: Use kernel Atomic type in docs example
Date: Tue, 2 Dec 2025 17:36:44 -0800	[thread overview]
Message-ID: <aS-ULCZAdj_l_j63@tardis.local> (raw)
In-Reply-To: <20251203000411.30434-1-fujita.tomonori@gmail.com>

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
> 
> 

      reply	other threads:[~2025-12-03  1:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aS-ULCZAdj_l_j63@tardis.local \
    --to=boqun.feng@gmail.com \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=dakr@kernel.org \
    --cc=fujita.tomonori@gmail.com \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rafael@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).