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

"Alexandre Courbot" <[email protected]>
Newsgroups gmane.linux.kernel.rust,gmane.linux.power-management.general,gmane.linux.kernel,gmane.comp.video.dri.devel,gmane.linux.ports.riscv,gmane.linux.pwm,gmane.linux.kernel.clk
Message-ID <[email protected]>
On Mon Jul 6, 2026 at 11:37 PM JST, 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.
>
> Signed-off-by: Daniel Almeida <[email protected]>

Reviewed-by: Alexandre Courbot <[email protected]>

One nit below.

> ---
>  rust/kernel/clk.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 46 insertions(+)
>
> diff --git a/rust/kernel/clk.rs b/rust/kernel/clk.rs
> index dd5fd656271e..b9a44f83843a 100644
> --- a/rust/kernel/clk.rs
> +++ b/rust/kernel/clk.rs
> @@ -96,6 +96,52 @@ impl Sealed for super::Prepared {}
>          impl Sealed for super::Enabled {}
>      }
>  
> +    /// Obtains and enables a [`devres`]-managed [`Clk`] for a bound device.
> +    ///
> +    /// [`devres`]: crate::devres::Devres
> +    #[inline]
> +    pub fn devm_enable(dev: &Device<Bound>, name: Option<&CStr>) -> Result {
> +        let name = name.map_or(ptr::null(), |n| n.as_char_ptr());
> +
> +        // SAFETY: It is safe to call [`devm_clk_get_enabled`] with a valid
> +        // device pointer.
> +        from_err_ptr(unsafe { bindings::devm_clk_get_enabled(dev.as_raw(), name) })?;
> +        Ok(())
> +    }
> +
> +    /// Obtains and enables a [`devres`]-managed [`Clk`] for a bound device.
> +    ///
> +    /// This does not print any error messages if the clock is not found.

This sounds like a clock not being found returns an error, but no
message is printed.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.