[tip: locking/core] rust: sync: Make Guard::new() public

From: tip-bot2 for Lyude Paul
Date: Tue Dec 24 2024 - 13:54:16 EST


The following commit has been merged into the locking/core branch of tip:

Commit-ID: daa03fe50ec376aeadd63a264c471c56af194e83
Gitweb: https://git.kernel.org/tip/daa03fe50ec376aeadd63a264c471c56af194e83
Author: Lyude Paul <lyude@xxxxxxxxxx>
AuthorDate: Tue, 19 Nov 2024 18:11:04 -05:00
Committer: Boqun Feng <boqun.feng@xxxxxxxxx>
CommitterDate: Thu, 19 Dec 2024 14:04:42 -08:00

rust: sync: Make Guard::new() public

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@xxxxxxxxxx>
Reviewed-by: Filipe Xavier <felipe_life@xxxxxxxx>
Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
Signed-off-by: Boqun Feng <boqun.feng@xxxxxxxxx>
Link: https://lore.kernel.org/r/20241119231146.2298971-3-lyude@xxxxxxxxxx
---
rust/kernel/sync/lock.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/sync/lock.rs b/rust/kernel/sync/lock.rs
index 57dc2e9..72dbf3f 100644
--- a/rust/kernel/sync/lock.rs
+++ b/rust/kernel/sync/lock.rs
@@ -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,