lock.rs (e7b9b1ff1d49e2117f2d78fa5f11b0d006c169f7) lock.rs (b6cda913bba42e1fdad82df41d906ff603319743)
1// SPDX-License-Identifier: GPL-2.0
2
3//! Generic kernel lock and guard.
4//!
5//! It contains a generic Rust lock and guard that allow for different backends (e.g., mutexes,
6//! spinlocks, raw spinlocks) to be provided with minimal effort.
7
8use super::LockClassKey;

--- 7 unchanged lines hidden (view full) ---

16/// The "backend" of a lock.
17///
18/// It is the actual implementation of the lock, without the need to repeat patterns used in all
19/// locks.
20///
21/// # Safety
22///
23/// - Implementers must ensure that only one thread/CPU may access the protected data once the lock
1// SPDX-License-Identifier: GPL-2.0
2
3//! Generic kernel lock and guard.
4//!
5//! It contains a generic Rust lock and guard that allow for different backends (e.g., mutexes,
6//! spinlocks, raw spinlocks) to be provided with minimal effort.
7
8use super::LockClassKey;

--- 7 unchanged lines hidden (view full) ---

16/// The "backend" of a lock.
17///
18/// It is the actual implementation of the lock, without the need to repeat patterns used in all
19/// locks.
20///
21/// # Safety
22///
23/// - Implementers must ensure that only one thread/CPU may access the protected data once the lock
24/// is owned, that is, between calls to `lock` and `unlock`.
24/// is owned, that is, between calls to `lock` and `unlock`.
25/// - Implementers must also ensure that `relock` uses the same locking method as the original
25/// - Implementers must also ensure that `relock` uses the same locking method as the original
26/// lock operation.
26/// lock operation.
27pub unsafe trait Backend {
28 /// The state required by the lock.
29 type State;
30
31 /// The state required to be kept between lock and unlock.
32 type GuardState;
33
34 /// Initialises the lock.

--- 156 unchanged lines hidden ---
27pub unsafe trait Backend {
28 /// The state required by the lock.
29 type State;
30
31 /// The state required to be kept between lock and unlock.
32 type GuardState;
33
34 /// Initialises the lock.

--- 156 unchanged lines hidden ---