Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rust: devres: fix doctest build under `!CONFIG_PCI`

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>
Link: https://lore.kernel.org/r/20250511182533.1016163-1-ojeda@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

authored by

Miguel Ojeda and committed by
Danilo Krummrich
42055939 b75a99e1

+1
+1
rust/kernel/devres.rs
··· 195 195 /// # Example 196 196 /// 197 197 /// ```no_run 198 + /// # #![cfg(CONFIG_PCI)] 198 199 /// # use kernel::{device::Core, devres::Devres, pci}; 199 200 /// 200 201 /// fn from_core(dev: &pci::Device<Core>, devres: Devres<pci::Bar<0x4>>) -> Result {