diff options
| author | 2025-10-21 23:53:24 -0400 | |
|---|---|---|
| committer | 2025-11-12 08:56:42 -0800 | |
| commit | f74cf399e02e24c544b0bd4b1fe8fa2c5ae30b18 (patch) | |
| tree | d6c6c54286ff79dba2a36371514a20fdd1932714 /samples/rust/rust_debugfs_scoped.rs | |
| parent | rust: sync: atomic: Implement Debug for Atomic<Debug> (diff) | |
| download | linux-rng-f74cf399e02e24c544b0bd4b1fe8fa2c5ae30b18.tar.xz linux-rng-f74cf399e02e24c544b0bd4b1fe8fa2c5ae30b18.zip | |
rust: debugfs: Replace the usage of Rust native atomics
Rust native atomics are not allowed to use in kernel due to the mismatch
of memory model with Linux kernel memory model, hence remove the usage
of Rust native atomics in debufs.
Reviewed-by: Matthew Maurer <mmaurer@google.com>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Tested-by: David Gow <davidgow@google.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://patch.msgid.link/20251022035324.70785-4-boqun.feng@gmail.com
Diffstat (limited to 'samples/rust/rust_debugfs_scoped.rs')
| -rw-r--r-- | samples/rust/rust_debugfs_scoped.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/samples/rust/rust_debugfs_scoped.rs b/samples/rust/rust_debugfs_scoped.rs index b0c4e76b123e..9f0ec5f24cda 100644 --- a/samples/rust/rust_debugfs_scoped.rs +++ b/samples/rust/rust_debugfs_scoped.rs @@ -6,9 +6,9 @@ //! `Scope::dir` to create a variety of files without the need to separately //! track them all. -use core::sync::atomic::AtomicUsize; use kernel::debugfs::{Dir, Scope}; use kernel::prelude::*; +use kernel::sync::atomic::Atomic; use kernel::sync::Mutex; use kernel::{c_str, new_mutex, str::CString}; @@ -62,7 +62,7 @@ fn create_file_write( let file_name = CString::try_from_fmt(fmt!("{name_str}"))?; for sub in items { nums.push( - AtomicUsize::new(sub.parse().map_err(|_| EINVAL)?), + Atomic::<usize>::new(sub.parse().map_err(|_| EINVAL)?), GFP_KERNEL, )?; } @@ -109,7 +109,7 @@ impl ModuleData { struct DeviceData { name: CString, - nums: KVec<AtomicUsize>, + nums: KVec<Atomic<usize>>, } fn init_control(base_dir: &Dir, dyn_dirs: Dir) -> impl PinInit<Scope<ModuleData>> + '_ { |
