diff options
author | Danilo Krummrich <dakr@kernel.org> | 2025-07-13 20:26:53 +0200 |
---|---|---|
committer | Danilo Krummrich <dakr@kernel.org> | 2025-07-15 14:46:13 +0200 |
commit | 85aa5b16fef7040213581df9ff093dae27bf8675 (patch) | |
tree | 85e6b5292347a4db1e4ca285314deff3b577c34d /rust/kernel/devres.rs | |
parent | 91ae26b06aab476bdd8b56cd99e127f029490330 (diff) |
rust: devres: provide an accessor for the device
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>
Diffstat (limited to 'rust/kernel/devres.rs')
-rw-r--r-- | rust/kernel/devres.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/rust/kernel/devres.rs b/rust/kernel/devres.rs index ac5e5d94ee96..152a89b78943 100644 --- a/rust/kernel/devres.rs +++ b/rust/kernel/devres.rs @@ -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 |