Skip to contentSkip to conversation

rust: Update PCI resource_start()/len() to return ResourceSize

PATCH In review Alistair Popple 2 participants 2 messages Aug 22, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rust: Update PCI resource_start()/len() to return ResourceSize

It's nicer to return native Rust types rather than the FFI bindings to a type so update the PCI resource bindings to return ResourceSize.

---
 rust/kernel/pci.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
rust/kernel/pci.rs +3 -3
index cae4e274f7766..ef949ff10a10a 100644
@@ -10,7 +10,7 @@
     devres::Devres,
     driver,
     error::{from_result, to_result, Result},
-    io::{Io, IoRaw},
+    io::{resource::ResourceSize, Io, IoRaw},
     irq::{self, IrqRequest},
     str::CStr,
     sync::aref::ARef,
@@ -437,7 +437,7 @@ pub fn subsystem_device_id(&self) -> u16 {
     }
 
     /// Returns the start of the given PCI bar resource.
-    pub fn resource_start(&self, bar: u32) -> Result<bindings::resource_size_t> {
+    pub fn resource_start(&self, bar: u32) -> Result<ResourceSize> {
         if !Bar::index_is_valid(bar) {
             return Err(EINVAL);
         }
@@ -449,7 +449,7 @@ pub fn resource_start(&self, bar: u32) -> Result<bindings::resource_size_t> {
     }
 
     /// Returns the size of the given PCI bar resource.
-    pub fn resource_len(&self, bar: u32) -> Result<bindings::resource_size_t> {
+    pub fn resource_len(&self, bar: u32) -> Result<ResourceSize> {
         if !Bar::index_is_valid(bar) {
             return Err(EINVAL);
         }
Signature · 1 line
2.47.2
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Alistair Popple

It's nicer to return native Rust types rather than the FFI bindings to a type so update the PCI resource bindings to return ResourceSize.

rust/kernel/pci.rs line 13

Quoted 13 lines
 rust/kernel/pci.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
rust/kernel/pci.rs +1 -1
index cae4e274f7766..ef949ff10a10a 100644
@@ -10,7 +10,7 @@
     devres::Devres,
     driver,
     error::{from_result, to_result, Result},
-    io::{Io, IoRaw},
+    io::{resource::ResourceSize, Io, IoRaw},

Maybe we want ResourceSize re-exported from kernel::io to make this simpler?

Alice