Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions rust/kernel/revocable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ impl<T> Revocable<T> {
data: ManuallyDrop::new(UnsafeCell::new(data)),
}
}
}

impl<T: ?Sized> Revocable<T> {
/// Tries to access the \[revocable\] wrapped object.
///
/// Returns `None` if the object has been revoked and is therefore no longer accessible.
Expand Down Expand Up @@ -125,12 +127,12 @@ impl<T: ?Sized> Drop for Revocable<T> {
/// # Invariants
///
/// The RCU read-side lock is held while the guard is alive.
pub struct RevocableGuard<'a, T> {
pub struct RevocableGuard<'a, T: ?Sized> {
data_ref: *const T,
_p: PhantomData<&'a ()>,
}

impl<T> RevocableGuard<'_, T> {
impl<T: ?Sized> RevocableGuard<'_, T> {
fn new(data_ref: *const T) -> Self {
// SAFETY: Just an FFI call, there are no further requirements.
unsafe { bindings::rcu_read_lock() };
Expand All @@ -143,14 +145,14 @@ impl<T> RevocableGuard<'_, T> {
}
}

impl<T> Drop for RevocableGuard<'_, T> {
impl<T: ?Sized> Drop for RevocableGuard<'_, T> {
fn drop(&mut self) {
// SAFETY: By the type invariants, we know that we hold the RCU read-side lock.
unsafe { bindings::rcu_read_unlock() };
}
}

impl<T> Deref for RevocableGuard<'_, T> {
impl<T: ?Sized> Deref for RevocableGuard<'_, T> {
type Target = T;

fn deref(&self) -> &Self::Target {
Expand Down