[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250306044028.5d2w4og2juclktqs@vireshk-i7>
Date: Thu, 6 Mar 2025 10:10:28 +0530
From: Viresh Kumar <viresh.kumar@...aro.org>
To: Stephen Boyd <sboyd@...nel.org>
Cc: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>,
Michael Turquette <mturquette@...libre.com>,
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 <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
Russell King <linux@...linux.org.uk>, linux-clk@...r.kernel.org,
linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org,
Vincent Guittot <vincent.guittot@...aro.org>,
Daniel Almeida <daniel.almeida@...labora.com>
Subject: Re: [PATCH V3 2/2] rust: Add initial clk abstractions
On 05-03-25, 14:31, Stephen Boyd wrote:
> Does this mean that a clk consumer has to keep the Result returned from
> enable() in scope until they want to disable the clk?
Yes and no.
> I don't see how
> that makes sense, because most of the time a consumer will enable a clk
> during probe and leave it enabled until system suspend or runtime PM
> suspend time. At that point, they would disable the clk explicitly with
> disable(), but now they would need to drop a reference to do that?
Broadly there are two type of clk users I believe:
1. clk is enabled / disabled from same routine:
In this case the result can be kept in a local variable and the matching
cleanup fn will be called at exit.
fn transfer_data(...) -> Result {
let _guard = clk.enable()?;
...
transfer-data here
...
// clk.disable() will be called automatically as soon as _guard goes out
// of scope.
}
2. clk is enabled / disabled from different routines:
In this case the caller needs to call dismiss to avoid the automatic freeing
of resource. Alternatively the returned value can be stored too somewhere,
but I am not sure if it what users will end up doing.
fn probe(...) -> Result {
clk.enable()?.dismiss();
...
}
fn remove (...) {
clk.disable();
...
}
--
viresh
Powered by blists - more mailing lists