[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250730062355.bqifrzvxfmaaugnk@vireshk-i7>
Date: Wed, 30 Jul 2025 11:53:55 +0530
From: Viresh Kumar <viresh.kumar@...aro.org>
To: Daniel Almeida <daniel.almeida@...labora.com>
Cc: Michael Turquette <mturquette@...libre.com>,
Stephen Boyd <sboyd@...nel.org>, Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
Danilo Krummrich <dakr@...nel.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Alexandre Courbot <acourbot@...dia.com>, linux-clk@...r.kernel.org,
rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-pm@...r.kernel.org
Subject: Re: [PATCH] rust: clk: use the type-state pattern
On 29-07-25, 18:38, Daniel Almeida wrote:
> diff --git a/rust/kernel/clk.rs b/rust/kernel/clk.rs
> /// A reference-counted clock.
> ///
> /// Rust abstraction for the C [`struct clk`].
> ///
> + /// A [`Clk`] instance represents a clock that can be in one of several
> + /// states: [`Unprepared`], [`Prepared`], or [`Enabled`].
> + ///
> + /// No action needs to be taken when a [`Clk`] is dropped. The calls to
> + /// `clk_unprepare()` and `clk_disable()` will be placed as applicable.
> + ///
> + /// An optional [`Clk`] is treated just like a regular [`Clk`], but its
> + /// inner `struct clk` pointer is `NULL`. This interfaces correctly with the
> + /// C API and also exposes all the methods of a regular [`Clk`] to users.
> + ///
> /// # Invariants
> ///
> /// A [`Clk`] instance holds either a pointer to a valid [`struct clk`] created by the C
> @@ -99,20 +160,39 @@ mod common_clk {
> /// Instances of this type are reference-counted. Calling [`Clk::get`] ensures that the
> /// allocation remains valid for the lifetime of the [`Clk`].
> ///
> - /// ## Examples
> + /// The [`Prepared`] state is associated with a single count of
> + /// `clk_prepare()`, and the [`Enabled`] state is associated with a single
> + /// count of `clk_enable()`, and the [`Enabled`] state is associated with a
> + /// single count of `clk_prepare` and `clk_enable()`.
You have mentioned the `Enabled` state twice. Also clk_prepare() ?
No objections from my side. Thanks.
--
viresh
Powered by blists - more mailing lists