[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DBBONAMQ0C3X.825M3H3R2IUY@kernel.org>
Date: Mon, 14 Jul 2025 11:49:44 +0200
From: "Danilo Krummrich" <dakr@...nel.org>
To: "Greg KH" <gregkh@...uxfoundation.org>
Cc: <rafael@...nel.org>, <ojeda@...nel.org>, <alex.gaynor@...il.com>,
<boqun.feng@...il.com>, <gary@...yguo.net>, <bjorn3_gh@...tonmail.com>,
<lossin@...nel.org>, <a.hindborg@...nel.org>, <aliceryhl@...gle.com>,
<tmgross@...ch.edu>, <daniel.almeida@...labora.com>,
<m.wilczynski@...sung.com>, <rust-for-linux@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] rust: device: implement Device::as_bound()
On Mon Jul 14, 2025 at 7:30 AM CEST, Greg KH wrote:
> On Sun, Jul 13, 2025 at 08:26:54PM +0200, Danilo Krummrich wrote:
>> Provide an unsafe functions for abstractions to convert a regular
>> &Device to a &Device<Bound>.
>>
>> This is useful for registrations that provide certain guarantees for the
>> scope of their callbacks, such as IRQs or certain class device
>> registrations (e.g. PWM, miscdevice).
>
> Do we have an example where this can be used today in the tree, or is
> this only for new stuff going forward that would use it?
There's miscdevice in tree, but to be fair, miscdevice doesn't need it without
my patch series [1] adding driver support for the existing miscdevice
abstractions; the patch in [2] out of this series would use it within
args_from_registration().
The PWM abstractions [3] need it in bound_parent_device(). The use-case is the
same as everywhere else, PWM chips never out-live driver unbind, hence they can
provide the corresponding bus device as &Device<Bound>.
The same is true for IRQ registrations [4]. free_irq() is guaranteed to be
called before driver unbind, hence we can provide a &Device<Bound> in the IRQ
callbacks.
Ultimately, we want to provide this "cookie" in any driver scope that can be
proven to be lifetime wise limited to device / driver unbind, so there'll be
much more users.
[1] https://lore.kernel.org/lkml/20250530142447.166524-1-dakr@kernel.org/
[2] https://lore.kernel.org/lkml/20250530142447.166524-7-dakr@kernel.org/
[3] https://lore.kernel.org/lkml/20250710-rust-next-pwm-working-fan-for-sending-v11-3-93824a16f9ec@samsung.com/
[4] https://lore.kernel.org/lkml/20250703-topics-tyr-request_irq-v6-3-74103bdc7c52@collabora.com/
Powered by blists - more mailing lists