[PATCH] samples: rust: fix endianness issue in rust_driver_pci
From: Marko Turk
Date: Sat Nov 01 2025 - 17:47:08 EST
QEMU PCI test device specifies all registers as little endian. OFFSET
register is converted properly, but the COUNT register is not.
Apply the same conversion to the COUNT register also.
Signed-off-by: Marko Turk <mt@xxxxxxxxxxxxxx>
Fixes: 685376d18e9a ("samples: rust: add Rust PCI sample driver")
---
samples/rust/rust_driver_pci.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/samples/rust/rust_driver_pci.rs b/samples/rust/rust_driver_pci.rs
index 55a683c39ed9..3cbb3139fbcf 100644
--- a/samples/rust/rust_driver_pci.rs
+++ b/samples/rust/rust_driver_pci.rs
@@ -56,7 +56,7 @@ fn testdev(index: &TestIndex, bar: &Bar0) -> Result<u32> {
// Note that we need `try_write8`, since `offset` can't be checked at compile-time.
bar.try_write8(data, offset)?;
- Ok(bar.read32(Regs::COUNT))
+ Ok(u32::from_le(bar.read32(Regs::COUNT)))
}
}
--
2.51.0