* [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
* 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
2026-01-19 13:49 ` FUJITA Tomonori
2026-01-19 14:07 ` Danilo Krummrich
1 sibling, 1 reply; 5+ 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] 5+ messages in thread
* Re: [PATCH v1] rust: debugfs: Use kernel Atomic type in docs example
2025-12-03 1:36 ` Boqun Feng
@ 2026-01-19 13:49 ` FUJITA Tomonori
2026-01-19 13:51 ` Danilo Krummrich
0 siblings, 1 reply; 5+ messages in thread
From: FUJITA Tomonori @ 2026-01-19 13:49 UTC (permalink / raw)
To: dakr, boqun.feng
Cc: fujita.tomonori, gregkh, ojeda, rafael, a.hindborg, aliceryhl,
bjorn3_gh, gary, lossin, rust-for-linux, tmgross
On Tue, 2 Dec 2025 17:36:44 -0800
Boqun Feng <boqun.feng@gmail.com> wrote:
> 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>
Can this patch be merged via the driver-core tree, or should it go
through a different tree?
> 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] 5+ messages in thread
* Re: [PATCH v1] rust: debugfs: Use kernel Atomic type in docs example
2026-01-19 13:49 ` FUJITA Tomonori
@ 2026-01-19 13:51 ` Danilo Krummrich
0 siblings, 0 replies; 5+ messages in thread
From: Danilo Krummrich @ 2026-01-19 13:51 UTC (permalink / raw)
To: FUJITA Tomonori
Cc: boqun.feng, gregkh, ojeda, rafael, a.hindborg, aliceryhl,
bjorn3_gh, gary, lossin, rust-for-linux, tmgross
On Mon Jan 19, 2026 at 2:49 PM CET, FUJITA Tomonori wrote:
> On Tue, 2 Dec 2025 17:36:44 -0800
> Boqun Feng <boqun.feng@gmail.com> wrote:
>
>> 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>
>
> Can this patch be merged via the driver-core tree, or should it go
> through a different tree?
Thanks for the ping, I will pick it up soon.
- Danilo
^ permalink raw reply [flat|nested] 5+ 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
@ 2026-01-19 14:07 ` Danilo Krummrich
1 sibling, 0 replies; 5+ messages in thread
From: Danilo Krummrich @ 2026-01-19 14:07 UTC (permalink / raw)
To: FUJITA Tomonori
Cc: gregkh, ojeda, rafael, a.hindborg, aliceryhl, bjorn3_gh,
boqun.feng, gary, lossin, rust-for-linux, tmgross
On Wed Dec 3, 2025 at 1:04 AM CET, 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>
Applied to driver-core-testing, thanks!
[ Use kernel vertical import style. - Danilo ]
^ permalink raw reply [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