mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Danilo Krummrich <dakr@kernel.org>
To: gregkh@linuxfoundation.org, rafael@kernel.org, ojeda@kernel.org,
	alex.gaynor@gmail.com, boqun.feng@gmail.com, gary@garyguo.net,
	bjorn3_gh@protonmail.com, lossin@kernel.org,
	a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu,
	daniel.almeida@collabora.com, m.wilczynski@samsung.com
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	Danilo Krummrich <dakr@kernel.org>
Subject: [PATCH 1/2] rust: devres: provide an accessor for the device
Date: Sun, 13 Jul 2025 20:26:53 +0200	[thread overview]
Message-ID: <20250713182737.64448-1-dakr@kernel.org> (raw)

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


             reply	other threads:[~2025-07-13 18:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-13 18:26 Danilo Krummrich [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250713182737.64448-1-dakr@kernel.org \
    --to=dakr@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=daniel.almeida@collabora.com \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=m.wilczynski@samsung.com \
    --cc=ojeda@kernel.org \
    --cc=rafael@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®