Re: [PATCH v5 3/4] rust: clk: add devres-managed clks

"Gary Guo" <[email protected]> Mon, 03 Aug 2026 13:32:19 +0100
Newsgroups org.kernel.vger.rust-for-linux,org.freedesktop.lists.dri-devel,org.infradead.lists.linux-riscv,org.kernel.vger.linux-clk,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pm,org.kernel.vger.linux-pwm
Message-ID <[email protected]>
On Mon Aug 3, 2026 at 4:57 AM BST, Alexandre Courbot wrote:
> On Mon Aug 3, 2026 at 3:34 AM JST, Gary Guo wrote:
>> On Mon Jul 6, 2026 at 3:37 PM BST, Daniel Almeida wrote:
>>> The clk API allows fine-grained control, but some drivers might be
>>> more interested in a "set and forget" API.
>>>
>>> Expand the current API to support this. The clock will automatically be
>>> disabled, unprepared and freed when the device is unbound from the bus
>>> without further intervention by the driver.
>>
>> Drivers could just put the enabled clock into their driver data.
>>
>> Given the general shift from devres to lifetime-scoped device resources,=
 do we
>> still have a need for this?
>
> This mimics what `Regulator` does; back then it was merged with quite
> some consensus [1].
>
> IIRC the justification for having this was that it's a nice
> fire-and-forget interface for those cases where you don't even want the
> driver to have a way to touch the resource after acquiring it, and it
> also ensures that the resource is dropped at unbind time even if the driv=
er
> data survives it for some reason (for instance, DRM open fds?).
>
> [1] https://lore.kernel.org/all/20250910-regulator-remove-dynamic-v3-2-07=
[email protected]/

I suppose we could integrate this with `DevRes` with a fire-and-forget API,=
 so you can do this to arbitrary resource.

I think just dropping `DevRes::inner` without running the destructor would =
do the job.

Perhaps