From a819edafc8915d3e6bb5192fadb64d5f8daddb92 Mon Sep 17 00:00:00 2001
From: Lyude Paul <lyude@redhat.com>
Date: Mon, 18 Nov 2024 17:53:48 -0500
Subject: [PATCH] DROP EVENTUALLY: rust: sync: Add SpinLockIrqGuard type alias

same for irq spinlocks. This will get dropped in the future since it's no
longer the solution that we're going to be going for upstream, but it is
taking forever for simple patches to be merged :(.

Signed-off-by: Lyude Paul <lyude@redhat.com>
---
 rust/kernel/sync.rs               | 9 ++++++++-
 rust/kernel/sync/lock/spinlock.rs | 8 ++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/rust/kernel/sync.rs b/rust/kernel/sync.rs
index 871f3d3bd55f9..df3bbe97203f3 100644
--- a/rust/kernel/sync.rs
+++ b/rust/kernel/sync.rs
@@ -17,7 +17,14 @@ pub use arc::{Arc, ArcBorrow, UniqueArc};
 pub use condvar::{new_condvar, CondVar, CondVarTimeoutResult};
 pub use lock::global::{global_lock, GlobalGuard, GlobalLock, GlobalLockBackend, GlobalLockedBy};
 pub use lock::mutex::{new_mutex, Mutex, MutexGuard};
-pub use lock::spinlock::{new_spinlock, new_spinlock_irq, SpinLock, SpinLockGuard, SpinLockIrq};
+pub use lock::spinlock::{
+    new_spinlock,
+    new_spinlock_irq,
+    SpinLock,
+    SpinLockGuard,
+    SpinLockIrq,
+    SpinLockIrqGuard,
+};
 pub use locked_by::LockedBy;
 
 /// Represents a lockdep class. It's a wrapper around C's `lock_class_key`.
diff --git a/rust/kernel/sync/lock/spinlock.rs b/rust/kernel/sync/lock/spinlock.rs
index 67fb3bddb2c0d..ef8ab88e70723 100644
--- a/rust/kernel/sync/lock/spinlock.rs
+++ b/rust/kernel/sync/lock/spinlock.rs
@@ -216,6 +216,14 @@ pub use new_spinlock_irq;
 /// ```
 pub type SpinLockIrq<T> = super::Lock<T, SpinLockIrqBackend>;
 
+/// A [`Guard`] acquired from locking a [`SpinLockIrq`].
+///
+/// This is simply a type alias for a [`Guard`] returned from locking a [`SpinLockIrq`]. It will
+/// unlock the [`SpinLockIrq`] upon being dropped.
+///
+/// [`Guard`]: super::Guard
+pub type SpinLockIrqGuard<'a, T: ?Sized> = super::Guard<'a, T, SpinLockIrqBackend>;
+
 /// A kernel `spinlock_t` lock backend that is acquired in no-irq contexts.
 pub struct SpinLockIrqBackend;
 
-- 
GitLab