On Thu Jan 22, 2026 at 2:44 PM CET, Maxime Ripard wrote:
> On Mon, Jan 19, 2026 at 03:37:17PM +0100, Danilo Krummrich wrote:
>> I don't see the issue with devm_regmap_init_mmio_clk()? It takes a reference
>> count of the clock and prepares it when called and unprepares the clk in 
>> drops
>> its reference in regmap_mmio_free_context() called from the devres callback.
>> 
>> That something we can easily do with the current API, no?
>
> The current one, yes. Doing that in the API suggested here would involve
> some boilerplate in all those drivers they don't have right now.

No, I did mean the API suggested here.

If you would implement something like devm_regmap_init_mmio_clk() in Rust with
this API, you'd have some object like

        struct RegmapResource<T: Backend, R: Resource> {
            map: Regmap<T>,
            res: R,
        }

and a concrete instance could have the following type

        RegmapResource<MmIo, Clk<Prepared>>

So, eventually you could have:

        fn devm_regmap_init_mmio_clk(dev: &Device<Bound>,  name: &CStr, ...) -> 
... {
            let clk: Clk<Prepared> = Clk::get(dev, name)?;
            let regmap = RegmapResource::new(..., clk);

            Devres::new(dev, regmap)
        }

Of course, we would never design the API in this way, as we have generic I/O
backends and register abstractions, and we'd also not have
devm_regmap_init_mmio_clk() as a constructor for a RegmapResource type, but you
get the idea.

Reply via email to