rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rust: devres: fix doctest build under `!CONFIG_PCI`
@ 2025-05-11 18:25 Miguel Ojeda
  2025-05-11 18:28 ` Miguel Ojeda
  2025-05-12  7:47 ` Danilo Krummrich
  0 siblings, 2 replies; 3+ messages in thread
From: Miguel Ojeda @ 2025-05-11 18:25 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Miguel Ojeda, Alex Gaynor
  Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, rust-for-linux,
	linux-kernel, patches

The doctest requires `CONFIG_PCI`:

    error[E0432]: unresolved import `kernel::pci`
        --> rust/doctests_kernel_generated.rs:2689:44
         |
    2689 | use kernel::{device::Core, devres::Devres, pci};
         |                                            ^^^ no `pci` in the root
         |
    note: found an item that was configured out
        --> rust/kernel/lib.rs:96:9
    note: the item is gated here
        --> rust/kernel/lib.rs:95:1

Thus conditionally compile it (which still checks the syntax).

Fixes: f301cb978c06 ("rust: devres: implement Devres::access()")
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
I noticed this in next-20250509 -- as usual, please feel free to fixup
it (or not) as preferred. Thanks!

 rust/kernel/devres.rs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/rust/kernel/devres.rs b/rust/kernel/devres.rs
index b67247db92c7..0f79a2ec9474 100644
--- a/rust/kernel/devres.rs
+++ b/rust/kernel/devres.rs
@@ -195,6 +195,7 @@ pub fn new_foreign_owned(dev: &Device<Bound>, data: T, flags: Flags) -> Result {
     /// # Example
     ///
     /// ```no_run
+    /// # #![cfg(CONFIG_PCI)]
     /// # use kernel::{device::Core, devres::Devres, pci};
     ///
     /// fn from_core(dev: &pci::Device<Core>, devres: Devres<pci::Bar<0x4>>) -> Result {

base-commit: ed61cb3d78d585209ec775933078e268544fe9a4
--
2.49.0

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

* Re: [PATCH] rust: devres: fix doctest build under `!CONFIG_PCI`
  2025-05-11 18:25 [PATCH] rust: devres: fix doctest build under `!CONFIG_PCI` Miguel Ojeda
@ 2025-05-11 18:28 ` Miguel Ojeda
  2025-05-12  7:47 ` Danilo Krummrich
  1 sibling, 0 replies; 3+ messages in thread
From: Miguel Ojeda @ 2025-05-11 18:28 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	rust-for-linux, linux-kernel, patches

On Sun, May 11, 2025 at 8:26 PM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> Thus conditionally compile it (which still checks the syntax).

i.e. "...even when disabled)."

Cheers,
Miguel

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

* Re: [PATCH] rust: devres: fix doctest build under `!CONFIG_PCI`
  2025-05-11 18:25 [PATCH] rust: devres: fix doctest build under `!CONFIG_PCI` Miguel Ojeda
  2025-05-11 18:28 ` Miguel Ojeda
@ 2025-05-12  7:47 ` Danilo Krummrich
  1 sibling, 0 replies; 3+ messages in thread
From: Danilo Krummrich @ 2025-05-12  7:47 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Alex Gaynor, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, rust-for-linux, linux-kernel, patches

On Sun, May 11, 2025 at 08:25:33PM +0200, Miguel Ojeda wrote:
> The doctest requires `CONFIG_PCI`:
> 
>     error[E0432]: unresolved import `kernel::pci`
>         --> rust/doctests_kernel_generated.rs:2689:44
>          |
>     2689 | use kernel::{device::Core, devres::Devres, pci};
>          |                                            ^^^ no `pci` in the root
>          |
>     note: found an item that was configured out
>         --> rust/kernel/lib.rs:96:9
>     note: the item is gated here
>         --> rust/kernel/lib.rs:95:1
> 
> Thus conditionally compile it (which still checks the syntax).
> 
> Fixes: f301cb978c06 ("rust: devres: implement Devres::access()")
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

Good catch!

Once we have the platform ioremap() abstractions [1], which are always built-in,
we should use those for the doctests. Maybe this could be a good first issue.

Applied to nova-next, thanks!

[1] https://lore.kernel.org/rust-for-linux/20250509-topics-tyr-platform_iomem-v8-3-e9f1725a40da@collabora.com/

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

end of thread, other threads:[~2025-05-12  7:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-11 18:25 [PATCH] rust: devres: fix doctest build under `!CONFIG_PCI` Miguel Ojeda
2025-05-11 18:28 ` Miguel Ojeda
2025-05-12  7:47 ` Danilo Krummrich

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).