Change LazyRevocable to use the existing HazPtrRevocable backend instead
of the RCU-based Revocable. init() now returns HazPtrRevokeHandle and
try_access(ctx) forwards to the hazptr-based implementation.

Signed-off-by: Alvin Sun <[email protected]>
---
 rust/kernel/revocable.rs | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/rust/kernel/revocable.rs b/rust/kernel/revocable.rs
index eabb76ce92c43..e974c75a90ec0 100644
--- a/rust/kernel/revocable.rs
+++ b/rust/kernel/revocable.rs
@@ -421,7 +421,7 @@ fn deref(&self) -> &Self::Target {
 #[pin_data]
 pub struct LazyRevocable<T> {
     #[pin]
-    once: SetOnce<Revocable<T>>,
+    once: SetOnce<HazPtrRevocable<T>>,
 }
 
 impl<T> LazyRevocable<T> {
@@ -440,18 +440,22 @@ pub const fn new() -> Self {
     pub fn init<E: Into<Error>>(
         self: Pin<&Self>,
         init: impl PinInit<T, E>,
-    ) -> Result<RevokeHandle<'_, T>> {
+    ) -> Result<HazPtrRevokeHandle<'_, T>> {
         // SAFETY: `once` is structurally pinned.
         let once = unsafe { self.map_unchecked(|x| &x.once) };
-        let revocable = once.pin_init(Revocable::new(init))?;
-        Ok(RevokeHandle::new(revocable))
+        let revocable = once.pin_init(HazPtrRevocable::new(init))?;
+        Ok(HazPtrRevokeHandle::new(revocable))
     }
 
     /// Tries to access the revocable wrapped object.
     ///
-    /// Returns `None` if the object has not been initialized, or it has been 
revoked and is therefore no longer accessible.
-    pub fn try_access(&self) -> Option<RevocableGuard<'_, T>> {
-        self.once.as_ref()?.try_access()
+    /// Returns `None` if the object has not been initialized, or it has been 
revoked and is
+    /// therefore no longer accessible.
+    pub fn try_access<'a>(
+        &self,
+        ctx: Pin<&'a mut HazptrCtx>,
+    ) -> Option<HazPtrRevocableGuard<'a, T>> {
+        self.once.as_ref()?.try_access(ctx)
     }
 }
 

-- 
2.43.0


Reply via email to