aboutsummaryrefslogtreecommitdiffstats
path: root/rust/kernel/sync
diff options
context:
space:
mode:
authorLyude Paul <lyude@redhat.com>2024-11-20 17:26:29 -0500
committerBoqun Feng <boqun.feng@gmail.com>2024-12-19 14:04:42 -0800
commiteb5ccb038284dc0e69822d71aafcbf7b57394aad (patch)
treeef0e1d0ae3f28f48eecf29772cf8e2f321f1dec3 /rust/kernel/sync
parentrust: sync: Add MutexGuard type alias (diff)
downloadlinux-eb5ccb038284dc0e69822d71aafcbf7b57394aad.tar.gz
linux-eb5ccb038284dc0e69822d71aafcbf7b57394aad.zip
rust: sync: Add SpinLockGuard type alias
A simple helper alias for code that needs to deal with Guard types returned from SpinLocks. Signed-off-by: Lyude Paul <lyude@redhat.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Link: https://lore.kernel.org/r/20241120222742.2490495-3-lyude@redhat.com
Diffstat (limited to 'rust/kernel/sync')
-rw-r--r--rust/kernel/sync/lock/spinlock.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/rust/kernel/sync/lock/spinlock.rs b/rust/kernel/sync/lock/spinlock.rs
index 9f4d128bed98..081c0220013b 100644
--- a/rust/kernel/sync/lock/spinlock.rs
+++ b/rust/kernel/sync/lock/spinlock.rs
@@ -87,6 +87,14 @@ pub type SpinLock<T> = super::Lock<T, SpinLockBackend>;
/// A kernel `spinlock_t` lock backend.
pub struct SpinLockBackend;
+/// A [`Guard`] acquired from locking a [`SpinLock`].
+///
+/// This is simply a type alias for a [`Guard`] returned from locking a [`SpinLock`]. It will unlock
+/// the [`SpinLock`] upon being dropped.
+///
+/// [`Guard`]: super::Guard
+pub type SpinLockGuard<'a, T> = super::Guard<'a, T, SpinLockBackend>;
+
// SAFETY: The underlying kernel `spinlock_t` object ensures mutual exclusion. `relock` uses the
// default implementation that always calls the same locking method.
unsafe impl super::Backend for SpinLockBackend {