Re: [PATCH v6 6/7] rust: clk: add `ExclusiveClk`
From: Daniel Almeida
Date: Tue Oct 13 2026 - 13:34:10 EST
> On 13 Oct 2026, at 14:07, Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx> wrote:
>
> Some drivers derive their configuration from a clock rate and cannot
> tolerate the rate changing underneath them. In C, they claim rate
> exclusivity with clk_rate_exclusive_get(), after which the clock
> framework refuses rate changes from other consumers until
> clk_rate_exclusive_put() is called.
>
> Add ExclusiveClk<T>, which takes a Clk<T> in any state and holds rate
> exclusivity until it is dropped. ExclusiveClk::new() calls
> clk_rate_exclusive_get(), and dropping the ExclusiveClk or calling
> ExclusiveClk::into_inner() calls clk_rate_exclusive_put().
> ExclusiveClk dereferences to the Clk<T>, so the rate can still be read
> and changed through it. Since a Clk cannot be cloned, the ExclusiveClk
> is the only handle to the consumer that holds the exclusivity.
>
> pwm-th1520 is the first user, in the next patch.
>
> Co-developed-by: Maurice Hieronymus <mhi@xxxxxxxxxxx>
> Signed-off-by: Maurice Hieronymus <mhi@xxxxxxxxxxx>
Maurice, I changed a few things in the design, so I took ownership with
your co-developed-by tag.
Let me know if that works for you, or what you would rather see instead.
— Daniel