diff options
author | Aliet Exposito Garcia <aliet.exposito@gmail.com> | 2024-09-18 18:51:15 -0400 |
---|---|---|
committer | Miguel Ojeda <ojeda@kernel.org> | 2024-10-07 21:39:58 +0200 |
commit | 1f0433d07ab270d439088285882e903617c5d4d5 (patch) | |
tree | 0529a59704066bab6cc61c2c46d72aaa15969dc5 /rust/kernel/task.rs | |
parent | 67b3fa4288fa634a69ac7f559b6d2a57df0ad586 (diff) |
rust: kernel: move `ARef<T>` and `AlwaysRefCounted` to new `sync::aref` module
Refactor the `ARef` type and `AlwaysRefCounted` trait from `types.rs`
into a new `sync/aref.rs` module:
- Add `rust/kernel/sync/aref.rs` with the definitions of `ARef` and
`AlwaysRefCounted`.
- Remove the same type and trait definitions from `rust/kernel/types.rs`.
- Update relevant files to import `ARef` and `AlwaysRefCounted` from
`sync/aref.rs`.
The type and trait definitions remain unchanged.
Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1117
Signed-off-by: Aliet Exposito Garcia <aliet.exposito@gmail.com>
Reviewed-by: Fiona Behrens <me@kloenk.dev>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20240918225115.2309224-3-aliet.exposito@gmail.com
[ Rebased on top of the lints series, slightly reworded and removed
unneeded `use AlwaysRefCounted` in example. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust/kernel/task.rs')
-rw-r--r-- | rust/kernel/task.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/rust/kernel/task.rs b/rust/kernel/task.rs index 55dff7e088bf..0b358aceace6 100644 --- a/rust/kernel/task.rs +++ b/rust/kernel/task.rs @@ -61,7 +61,7 @@ macro_rules! current { /// incremented when creating `State` and decremented when it is dropped: /// /// ``` -/// use kernel::{task::Task, types::ARef}; +/// use kernel::{task::Task, sync::aref::ARef}; /// /// struct State { /// creator: ARef<Task>, @@ -164,7 +164,7 @@ impl Task { } // SAFETY: The type invariants guarantee that `Task` is always refcounted. -unsafe impl crate::types::AlwaysRefCounted for Task { +unsafe impl crate::sync::aref::AlwaysRefCounted for Task { fn inc_ref(&self) { // SAFETY: The existence of a shared reference means that the refcount is nonzero. unsafe { bindings::get_task_struct(self.0.get()) }; |