From: "Benno Lossin" <lossin@kernel.org>
To: "Danilo Krummrich" <dakr@kernel.org>
Cc: <gregkh@linuxfoundation.org>, <rafael@kernel.org>,
<ojeda@kernel.org>, <alex.gaynor@gmail.com>,
<boqun.feng@gmail.com>, <gary@garyguo.net>,
<bjorn3_gh@protonmail.com>, <a.hindborg@kernel.org>,
<aliceryhl@google.com>, <tmgross@umich.edu>,
<david.m.ertman@intel.com>, <ira.weiny@intel.com>,
<leon@kernel.org>, <kwilczynski@kernel.org>,
<bhelgaas@google.com>, <rust-for-linux@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-pci@vger.kernel.org>
Subject: Re: [PATCH v3 4/4] rust: devres: implement register_release()
Date: Fri, 27 Jun 2025 01:13:30 +0200 [thread overview]
Message-ID: <DAWUGWHZALC1.2FJDIDRG325F@kernel.org> (raw)
In-Reply-To: <aF1sEnxdJaVeBZ3x@cassiopeiae>
On Thu Jun 26, 2025 at 5:49 PM CEST, Danilo Krummrich wrote:
> On Thu, Jun 26, 2025 at 05:32:25PM +0200, Danilo Krummrich wrote:
>> On Thu, Jun 26, 2025 at 04:41:55PM +0200, Benno Lossin wrote:
>> > On Thu Jun 26, 2025 at 4:02 PM CEST, Danilo Krummrich wrote:
>> > > On Thu, Jun 26, 2025 at 01:15:34PM +0200, Danilo Krummrich wrote:
>> > >> On Thu, Jun 26, 2025 at 12:36:23PM +0200, Benno Lossin wrote:
>> > >> > Or, we could change `Release` to be:
>> > >> >
>> > >> > pub trait Release {
>> > >> > type Ptr: ForeignOwnable;
>> > >> >
>> > >> > fn release(this: Self::Ptr);
>> > >> > }
>> > >> >
>> > >> > and then `register_release` is:
>> > >> >
>> > >> > pub fn register_release<T: Release>(dev: &Device<Bound>, data: T::Ptr) -> Result
>> > >> >
>> > >> > This way, one can store a `Box<T>` and get access to the `T` at the end.
>> > >>
>> > >> I think this was also the case before? Well, it was P::Borrowed instead.
>> > >>
>> > >> > Or if they store the value in an `Arc<T>`, they have the option to clone
>> > >> > it and give it to somewhere else.
>> > >>
>> > >> Anyways, I really like this proposal of implementing the Release trait.
>> > >
>> > > One downside seems to be that the compiler cannot infer T anymore with this
>> > > function signature.
>> >
>> > Yeah... That's a bit annoying.
>> >
>> > We might be able to add an associated type to `ForeignOwnable` like
>> > `Target` or `Inner` or whatever.
>>
>> I think we already have `PointedTo` [1]? But I remember that I've seen a patch
>> to remove it again [2].
>
> Well, not exactly, I think. Arc, for instance, defines PointedTo as ArcInner<T>.
> So, I think we indeed want something different.
Yeah `PointedTo` is used to specify the type of the foreign pointer and
should go away soon.
---
Cheers,
Benno
prev parent reply other threads:[~2025-06-26 23:13 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-24 21:53 [PATCH v3 0/4] Improvements for Devres Danilo Krummrich
2025-06-24 21:53 ` [PATCH v3 1/4] rust: revocable: support fallible PinInit types Danilo Krummrich
2025-06-24 21:54 ` [PATCH v3 2/4] rust: devres: replace Devres::new_foreign_owned() Danilo Krummrich
2025-06-24 21:54 ` [PATCH v3 3/4] rust: devres: get rid of Devres' inner Arc Danilo Krummrich
2025-06-26 4:13 ` Boqun Feng
2025-06-26 10:01 ` Danilo Krummrich
2025-06-26 10:27 ` Benno Lossin
2025-06-26 11:07 ` Danilo Krummrich
2025-06-26 11:40 ` Danilo Krummrich
2025-06-26 13:09 ` Benno Lossin
2025-06-26 13:07 ` Benno Lossin
2025-06-26 19:47 ` Danilo Krummrich
2025-06-26 20:04 ` Boqun Feng
2025-06-24 21:54 ` [PATCH v3 4/4] rust: devres: implement register_release() Danilo Krummrich
2025-06-26 10:36 ` Benno Lossin
2025-06-26 11:15 ` Danilo Krummrich
2025-06-26 13:13 ` Benno Lossin
2025-06-26 14:02 ` Danilo Krummrich
2025-06-26 14:41 ` Benno Lossin
2025-06-26 15:32 ` Danilo Krummrich
2025-06-26 15:49 ` Danilo Krummrich
2025-06-26 23:13 ` Benno Lossin [this message]
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=DAWUGWHZALC1.2FJDIDRG325F@kernel.org \
--to=lossin@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=david.m.ertman@intel.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=ira.weiny@intel.com \
--cc=kwilczynski@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.