[RFC PATCH 2/2] samples: rust: pci: exercise config space accessors

Zijing Zhang posted 2 patches 1 week, 3 days ago
[RFC PATCH 2/2] samples: rust: pci: exercise config space accessors
Posted by Zijing Zhang 1 week, 3 days ago
Use the new PCI config space accessors from the Rust PCI sample driver.

Signed-off-by: Zijing Zhang <zijing.zhang@ry.rs>
---
 samples/rust/rust_driver_pci.rs | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/samples/rust/rust_driver_pci.rs b/samples/rust/rust_driver_pci.rs
index fa677991a5c4..1089352626fc 100644
--- a/samples/rust/rust_driver_pci.rs
+++ b/samples/rust/rust_driver_pci.rs
@@ -68,11 +68,15 @@ impl pci::Driver for SampleDriver {
     fn probe(pdev: &pci::Device<Core>, info: &Self::IdInfo) -> impl PinInit<Self, Error> {
         pin_init::pin_init_scope(move || {
             let vendor = pdev.vendor_id();
+            let vendor_cfg = pdev.read_config_u16(0x00)?;
+            let device_cfg = pdev.read_config_u16(0x02)?;
             dev_dbg!(
                 pdev.as_ref(),
-                "Probe Rust PCI driver sample (PCI ID: {}, 0x{:x}).\n",
+                "Probe Rust PCI driver sample (PCI ID: {}, 0x{:x}; cfg: 0x{:04x}:0x{:04x}).\n",
                 vendor,
-                pdev.device_id()
+                pdev.device_id(),
+                vendor_cfg,
+                device_cfg,
             );
 
             pdev.enable_device_mem()?;
-- 
2.52.0