]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rust: sync: Make Guard::new() public
authorLyude Paul <lyude@redhat.com>
Tue, 19 Nov 2024 23:11:04 +0000 (18:11 -0500)
committerBoqun Feng <boqun.feng@gmail.com>
Thu, 19 Dec 2024 22:04:42 +0000 (14:04 -0800)
Since we added a `Lock::from_raw()` function previously, it makes sense
to also introduce an interface for creating a `Guard` from a reference
to a `Lock` for instances where we've derived the `Lock` from a raw
pointer and know that the lock is already acquired, there are such
usages in KMS API.

[Boqun: Add backquotes to type names, reformat the commit log, reword a
 bit on the usage of KMS API]

Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Filipe Xavier <felipe_life@live.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://lore.kernel.org/r/20241119231146.2298971-3-lyude@redhat.com
rust/kernel/sync/lock.rs

index 57dc2e90e50468d0a479cd330fcd8de2715af666..72dbf3fbb25914146687ea25733181b98c43df1b 100644 (file)
@@ -234,7 +234,7 @@ impl<'a, T: ?Sized, B: Backend> Guard<'a, T, B> {
     /// # Safety
     ///
     /// The caller must ensure that it owns the lock.
-    pub(crate) unsafe fn new(lock: &'a Lock<T, B>, state: B::GuardState) -> Self {
+    pub unsafe fn new(lock: &'a Lock<T, B>, state: B::GuardState) -> Self {
         Self {
             lock,
             state,