rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rust: opp: Move `cfg(CONFIG_OF)` attribute to the top of doc test
@ 2025-05-27  5:33 Viresh Kumar
  2025-05-27  8:39 ` Miguel Ojeda
  2025-05-27 13:33 ` Rafael J. Wysocki
  0 siblings, 2 replies; 4+ messages in thread
From: Viresh Kumar @ 2025-05-27  5:33 UTC (permalink / raw)
  To: Rafael J. Wysocki, Viresh Kumar, Nishanth Menon, Stephen Boyd,
	Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich
  Cc: Viresh Kumar, linux-pm, Vincent Guittot, Miguel Ojeda,
	rust-for-linux, linux-kernel

Move the `#[cfg(CONFIG_OF)]` attribute to the top of the documentation test
block and hide it. This applies the condition to the entire test and improves
readability.

Placing configuration flags like `CONFIG_OF` at the top serves as a clear
indicator of the conditions under which the example is valid, effectively
acting like configuration metadata for the example itself.

Suggested-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
Rafael,

Sorry for the trouble, one more patch to apply :(

 rust/kernel/opp.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/opp.rs b/rust/kernel/opp.rs
index c2bdc11f3999..a566fc3e7dcb 100644
--- a/rust/kernel/opp.rs
+++ b/rust/kernel/opp.rs
@@ -575,6 +575,7 @@ extern "C" fn config_regulators(
 /// frequency.
 ///
 /// ```
+/// # #![cfg(CONFIG_OF)]
 /// use kernel::clk::Hertz;
 /// use kernel::cpumask::Cpumask;
 /// use kernel::device::Device;
@@ -582,7 +583,6 @@ extern "C" fn config_regulators(
 /// use kernel::opp::Table;
 /// use kernel::types::ARef;
 ///
-/// #[cfg(CONFIG_OF)]
 /// fn get_table(dev: &ARef<Device>, mask: &mut Cpumask, freq: Hertz) -> Result<Table> {
 ///     let mut opp_table = Table::from_of_cpumask(dev, mask)?;
 ///
-- 
2.31.1.272.g89b43f80a514


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] rust: opp: Move `cfg(CONFIG_OF)` attribute to the top of doc test
  2025-05-27  5:33 [PATCH] rust: opp: Move `cfg(CONFIG_OF)` attribute to the top of doc test Viresh Kumar
@ 2025-05-27  8:39 ` Miguel Ojeda
  2025-05-27  8:45   ` Viresh Kumar
  2025-05-27 13:33 ` Rafael J. Wysocki
  1 sibling, 1 reply; 4+ messages in thread
From: Miguel Ojeda @ 2025-05-27  8:39 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Rafael J. Wysocki, Viresh Kumar, Nishanth Menon, Stephen Boyd,
	Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, linux-pm, Vincent Guittot,
	rust-for-linux, linux-kernel

On Tue, May 27, 2025 at 7:33 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> Sorry for the trouble, one more patch to apply :(

Sorry, to be clear, I meant it as a discussion, i.e. no need to send a
patch for this in a hurry!

It is just something we did for another example, but it is not a
guideline or anything yet (it may not be a good idea, in fact -- I was
hoping for others to chime in). Even if it were, there is no rush to
"fix" it :)

Thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] rust: opp: Move `cfg(CONFIG_OF)` attribute to the top of doc test
  2025-05-27  8:39 ` Miguel Ojeda
@ 2025-05-27  8:45   ` Viresh Kumar
  0 siblings, 0 replies; 4+ messages in thread
From: Viresh Kumar @ 2025-05-27  8:45 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Rafael J. Wysocki, Viresh Kumar, Nishanth Menon, Stephen Boyd,
	Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, linux-pm, Vincent Guittot,
	rust-for-linux, linux-kernel

On 27-05-25, 10:39, Miguel Ojeda wrote:
> Sorry, to be clear, I meant it as a discussion, i.e. no need to send a
> patch for this in a hurry!

Yeah, I know you started it as a discussion, but I did like it. And
honestly I didn't realize earlier that I can add this at the top of
the whole block (and hide it too), otherwise that would have been part
of my initial patch itself.

> It is just something we did for another example, but it is not a
> guideline or anything yet (it may not be a good idea, in fact -- I was
> hoping for others to chime in). Even if it were, there is no rush to
> "fix" it :)

That's why I didn't mark it as a fix, but just an improvement that I
agree with :)

Specially for this particular case, there is only function in this doc
test, and so marking the whole block with cfg looks better.

-- 
viresh

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] rust: opp: Move `cfg(CONFIG_OF)` attribute to the top of doc test
  2025-05-27  5:33 [PATCH] rust: opp: Move `cfg(CONFIG_OF)` attribute to the top of doc test Viresh Kumar
  2025-05-27  8:39 ` Miguel Ojeda
@ 2025-05-27 13:33 ` Rafael J. Wysocki
  1 sibling, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2025-05-27 13:33 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Rafael J. Wysocki, Viresh Kumar, Nishanth Menon, Stephen Boyd,
	Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, linux-pm, Vincent Guittot,
	Miguel Ojeda, rust-for-linux, linux-kernel

On Tue, May 27, 2025 at 7:33 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> Move the `#[cfg(CONFIG_OF)]` attribute to the top of the documentation test
> block and hide it. This applies the condition to the entire test and improves
> readability.
>
> Placing configuration flags like `CONFIG_OF` at the top serves as a clear
> indicator of the conditions under which the example is valid, effectively
> acting like configuration metadata for the example itself.
>
> Suggested-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> Rafael,
>
> Sorry for the trouble, one more patch to apply :(

No problem, applied.

Thanks!

>  rust/kernel/opp.rs | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/rust/kernel/opp.rs b/rust/kernel/opp.rs
> index c2bdc11f3999..a566fc3e7dcb 100644
> --- a/rust/kernel/opp.rs
> +++ b/rust/kernel/opp.rs
> @@ -575,6 +575,7 @@ extern "C" fn config_regulators(
>  /// frequency.
>  ///
>  /// ```
> +/// # #![cfg(CONFIG_OF)]
>  /// use kernel::clk::Hertz;
>  /// use kernel::cpumask::Cpumask;
>  /// use kernel::device::Device;
> @@ -582,7 +583,6 @@ extern "C" fn config_regulators(
>  /// use kernel::opp::Table;
>  /// use kernel::types::ARef;
>  ///
> -/// #[cfg(CONFIG_OF)]
>  /// fn get_table(dev: &ARef<Device>, mask: &mut Cpumask, freq: Hertz) -> Result<Table> {
>  ///     let mut opp_table = Table::from_of_cpumask(dev, mask)?;
>  ///
> --
> 2.31.1.272.g89b43f80a514
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-05-27 13:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-27  5:33 [PATCH] rust: opp: Move `cfg(CONFIG_OF)` attribute to the top of doc test Viresh Kumar
2025-05-27  8:39 ` Miguel Ojeda
2025-05-27  8:45   ` Viresh Kumar
2025-05-27 13:33 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).