Rust for Linux List
 help / color / mirror / Atom feed
From: "Gary Guo" <gary@garyguo.net>
To: "Jerome Brunet" <jbrunet@baylibre.com>,
	"Daniel Almeida" <daniel.almeida@collabora.com>
Cc: "Gary Guo" <gary@garyguo.net>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Michal Wilczynski" <m.wilczynski@samsung.com>,
	"Drew Fustini" <fustini@kernel.org>,
	"Guo Ren" <guoren@kernel.org>, "Fu Wei" <wefu@redhat.com>,
	"Uwe Kleine-König" <ukleinek@kernel.org>,
	"Stephen Boyd" <sboyd@kernel.org>,
	"Brian Masney" <bmasney+clk@redhat.com>,
	"Jerome Brunet" <jbrunet+clk@baylibre.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org, linux-riscv@lists.infradead.org,
	linux-pwm@vger.kernel.org, linux-clk@vger.kernel.org,
	rust-for-linux@vger.kernel.org,
	"Boris Brezillon" <boris.brezillon@collabora.com>,
	"Onur Özkan" <work@onurozkan.dev>,
	"Maurice Hieronymus" <mhi@mailbox.org>
Subject: Re: [PATCH v6 5/7] rust: clk: add devres-managed clks
Date: Fri, 27 Nov 2026 19:04:08 +0000	[thread overview]
Message-ID: <DN686PEEVSKX.2U3UDJGLRJCQZ@garyguo.net> (raw)
In-Reply-To: <179580269373.2809466.3866997464599192193.b4-reply@b4>

On Fri Nov 27, 2026 at 6:04 PM GMT, Jerome Brunet wrote:
> On 2026-11-18 11:47 -0300, Daniel Almeida wrote:
>> 
>> 
>> > On 18 Nov 2026, at 11:24, Gary Guo <gary@garyguo.net> wrote:
>> > 
>> > On Tue Oct 13, 2026 at 6:07 PM BST, Daniel Almeida wrote:
>> >> Many drivers only need a clock running for as long as the device is
>> >> bound and never touch it afterwards. In C, devm_clk_get_enabled() and
>> >> devm_clk_get_optional_enabled() cover this case.
>> >> 
>> >> Add devm_enable(), devm_enable_optional() and
>> >> devm_enable_optional_with_rate(), which wrap the C helpers. They return
>> >> no handle, so the driver keeps nothing in its data and cannot change the
>> >> state of the clock. The clock is disabled, unprepared and put when the
>> >> device is unbound.
>> >> 
>> >> This mirrors regulator::devm_enable() and devm_enable_optional().
>> >> 
>> >> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
>> >> Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
>> > 
>> > Given all the device resource lifetime changes, do we still need this now, or
>> > would putting a guard in driver private data to be dropped automatically upon
>> > unbind be sufficient?
>> 
>> I think we should still provide this. Many drivers only care that the clock be
>> enabled at a given rate, and do not care about the handle. I think this has
>> little to do with C or Rust and should be supported in Rust too.
>> 
>> — Daniel
>
> Gary, is this OK with you ? if it is, I can take as it is.

It's a bit against the trend that we're doing elsewhere where things that are
managed APIs are changed to become guards that gets embedded in drivers (so the
lifetime relationship is tracked by the type system). That said, clk/regulators
usually don't interact with other device resources, so probably keeping devm is
fine, so not a blocking concern from me.

That said, I'd like to hear Danilo's thought on this one.

Best,
Gary

  reply	other threads:[~2026-11-27 19:04 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 17:07 [PATCH v6 0/7] Clk improvements Daniel Almeida
2026-10-13 17:07 ` [PATCH v6 1/7] rust: clk: use 'kernel vertical style' for imports Daniel Almeida
2026-11-18 13:47   ` Alice Ryhl
2026-10-13 17:07 ` [PATCH v6 2/7] rust: clk: replace `OptionalClk` with `Clk::get_optional()` Daniel Almeida
2026-11-18 13:47   ` Alice Ryhl
2026-10-13 17:07 ` [PATCH v6 3/7] rust: clk: use the type-state pattern Daniel Almeida
2026-11-18 13:47   ` Alice Ryhl
2026-11-20 16:48   ` Jerome Brunet
2026-11-23 16:33     ` Daniel Almeida
2026-10-13 17:07 ` [PATCH v6 4/7] rust: clk: add guards for scoped prepare and enable Daniel Almeida
2026-11-18 13:47   ` Alice Ryhl
2026-10-13 17:07 ` [PATCH v6 5/7] rust: clk: add devres-managed clks Daniel Almeida
2026-11-18 13:47   ` Alice Ryhl
2026-11-18 14:24   ` Gary Guo
2026-11-18 14:47     ` Daniel Almeida
2026-11-27 18:04       ` Jerome Brunet
2026-11-27 19:04         ` Gary Guo [this message]
2026-10-13 17:07 ` [PATCH v6 6/7] rust: clk: add `ExclusiveClk` Daniel Almeida
2026-10-13 17:14   ` Daniel Almeida
2026-11-18 13:47   ` Alice Ryhl
2026-10-13 17:07 ` [PATCH v6 7/7] pwm: th1520: Lock clock rate with clk_rate_exclusive_get Daniel Almeida
2026-11-11 16:54 ` [PATCH v6 0/7] Clk improvements Daniel Almeida
2026-11-20 16:48   ` Jerome Brunet
2026-11-20 21:31     ` Miguel Ojeda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DN686PEEVSKX.2U3UDJGLRJCQZ@garyguo.net \
    --to=gary@garyguo.net \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=bmasney+clk@redhat.com \
    --cc=boqun@kernel.org \
    --cc=boris.brezillon@collabora.com \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=fustini@kernel.org \
    --cc=guoren@kernel.org \
    --cc=jbrunet+clk@baylibre.com \
    --cc=jbrunet@baylibre.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=lossin@kernel.org \
    --cc=m.wilczynski@samsung.com \
    --cc=mhi@mailbox.org \
    --cc=ojeda@kernel.org \
    --cc=rafael@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sboyd@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=ukleinek@kernel.org \
    --cc=viresh.kumar@linaro.org \
    --cc=wefu@redhat.com \
    --cc=work@onurozkan.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox