linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] rust: devres: provide an accessor for the device
@ 2025-07-13 18:26 Danilo Krummrich
  2025-07-13 18:26 ` [PATCH 2/2] rust: device: implement Device::as_bound() Danilo Krummrich
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Danilo Krummrich @ 2025-07-13 18:26 UTC (permalink / raw)
  To: gregkh, rafael, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, tmgross, daniel.almeida,
	m.wilczynski
  Cc: rust-for-linux, linux-kernel, Danilo Krummrich

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>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
---
 rust/kernel/devres.rs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/rust/kernel/devres.rs b/rust/kernel/devres.rs
index f43de3d77d61..a8a2d24cac24 100644
--- a/rust/kernel/devres.rs
+++ b/rust/kernel/devres.rs
@@ -204,6 +204,11 @@ fn remove_action(&self) -> bool {
         } == 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

base-commit: 3964d07dd821efe9680e90c51c86661a98e60a0f
-- 
2.50.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-07-15 20:30 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-13 18:26 [PATCH 1/2] rust: devres: provide an accessor for the device Danilo Krummrich
2025-07-13 18:26 ` [PATCH 2/2] rust: device: implement Device::as_bound() Danilo Krummrich
2025-07-13 19:37   ` Danilo Krummrich
2025-07-13 19:39   ` Benno Lossin
2025-07-14  5:30   ` Greg KH
2025-07-14  9:49     ` Danilo Krummrich
2025-07-14 13:24       ` Greg KH
2025-07-14 13:26         ` Danilo Krummrich
2025-07-15 20:30   ` Danilo Krummrich
2025-07-13 19:39 ` [PATCH 1/2] rust: devres: provide an accessor for the device Benno Lossin
2025-07-14  5:30 ` Greg KH
2025-07-15 20:29 ` Danilo Krummrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).