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

Configure Feed

Select the types of activity you want to include in your feed.

sample: rust: pci: add tests for config space routines

Add tests exercising the PCI configuration space helpers.

Suggested-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Zhi Wang <zhiw@nvidia.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://patch.msgid.link/20260121202212.4438-6-zhiw@nvidia.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

authored by

Zhi Wang and committed by
Danilo Krummrich
e62e48ad 4dc0bacb

+26
+26
samples/rust/rust_driver_pci.rs
··· 5 5 //! To make this driver probe, QEMU must be run with `-device pci-testdev`. 6 6 7 7 use kernel::{ 8 + device::Bound, 8 9 device::Core, 9 10 devres::Devres, 10 11 io::Io, ··· 66 65 67 66 Ok(bar.read32(Regs::COUNT)) 68 67 } 68 + 69 + fn config_space(pdev: &pci::Device<Bound>) { 70 + let config = pdev.config_space(); 71 + 72 + // TODO: use the register!() macro for defining PCI configuration space registers once it 73 + // has been move out of nova-core. 74 + dev_info!( 75 + pdev.as_ref(), 76 + "pci-testdev config space read8 rev ID: {:x}\n", 77 + config.read8(0x8) 78 + ); 79 + 80 + dev_info!( 81 + pdev.as_ref(), 82 + "pci-testdev config space read16 vendor ID: {:x}\n", 83 + config.read16(0) 84 + ); 85 + 86 + dev_info!( 87 + pdev.as_ref(), 88 + "pci-testdev config space read32 BAR 0: {:x}\n", 89 + config.read32(0x10) 90 + ); 91 + } 69 92 } 70 93 71 94 impl pci::Driver for SampleDriver { ··· 121 96 "pci-testdev data-match count: {}\n", 122 97 Self::testdev(info, bar)? 123 98 ); 99 + Self::config_space(pdev); 124 100 }, 125 101 pdev: pdev.into(), 126 102 }))