Re: [PATCH v6 5/7] rust: clk: add devres-managed clks

From: Gary Guo

Date: Wed Nov 18 2026 - 09:24:50 EST


On Tue Oct 13, 2026 at 6:07 PM BST, Daniel Almeida wrote:
> Many drivers only need a clock running for as long as the device is
> bound and never touch it afterwards. In C, devm_clk_get_enabled() and
> devm_clk_get_optional_enabled() cover this case.
>
> Add devm_enable(), devm_enable_optional() and
> devm_enable_optional_with_rate(), which wrap the C helpers. They return
> no handle, so the driver keeps nothing in its data and cannot change the
> state of the clock. The clock is disabled, unprepared and put when the
> device is unbound.
>
> This mirrors regulator::devm_enable() and devm_enable_optional().
>
> Reviewed-by: Alexandre Courbot <acourbot@xxxxxxxxxx>
> Signed-off-by: Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>

Given all the device resource lifetime changes, do we still need this now, or
would putting a guard in driver private data to be dropped automatically upon
unbind be sufficient?

Best,
Gary

> ---
> rust/kernel/clk.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 46 insertions(+)