]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rust: devres: provide an accessor for the device
authorDanilo Krummrich <dakr@kernel.org>
Sun, 13 Jul 2025 18:26:53 +0000 (20:26 +0200)
committerDanilo Krummrich <dakr@kernel.org>
Tue, 15 Jul 2025 12:46:13 +0000 (14:46 +0200)
Provide an accessor for the Device a Devres instance has been created
with.

For instance, this is useful when registrations want to provide a
&Device<Bound> for a scope that is protected by Devres.

Suggested-by: Benno Lossin <lossin@kernel.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Link: https://lore.kernel.org/r/20250713182737.64448-1-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
rust/kernel/devres.rs

index ac5e5d94ee9637c14ec58d0478f099c7f2777f28..152a89b78943866d20d585676b8ef7a91e86bd90 100644 (file)
@@ -204,6 +204,11 @@ impl<T: Send> Devres<T> {
         } == 0)
     }
 
+    /// Return a reference of the [`Device`] this [`Devres`] instance has been created with.
+    pub fn device(&self) -> &Device {
+        &self.dev
+    }
+
     /// Obtain `&'a T`, bypassing the [`Revocable`].
     ///
     /// This method allows to directly obtain a `&'a T`, bypassing the [`Revocable`], by presenting