[PATCH v6 4/7] rust: clk: add guards for scoped prepare and enable
Alice Ryhl
aliceryhl at google.com
Wed Nov 18 05:47:53 PST 2026
On Tue, Oct 13, 2026 at 02:07:43PM -0300, Daniel Almeida wrote:
> The state transitions consume the Clk, so a driver that keeps a
> Clk<Prepared> in its data cannot enable it for a short section without
> moving it out and back in. A clock handle also holds at most one count
> of clk_prepare() and one of clk_enable().
>
> Add EnabledGuard, PreparedGuard and PrepareEnabledGuard, returned by
> Clk::enable_guard(), Clk::prepare_guard() and
> Clk::prepare_enable_guard(). Each guard borrows the Clk, takes its count
> when it is created and releases it when it is dropped. It dereferences
> to the clock in the higher state, so a function that takes a
> &Clk<Enabled> also accepts an EnabledGuard. Several guards may borrow the
> same Clk, and the borrow keeps the Clk from being dropped or moved to
> another state while a guard is alive.
>
> There are no users yet.
>
> Suggested-by: Alexandre Courbot <acourbot at nvidia.com>
> Suggested-by: Gary Guo <gary at garyguo.net>
> Signed-off-by: Daniel Almeida <daniel.almeida at collabora.com>
Reviewed-by: Alice Ryhl <aliceryhl at google.com>
Alice
More information about the linux-riscv
mailing list