rust: pci: move iomap_region() to impl Device<Bound>
authorDanilo Krummrich <dakr@kernel.org>
Sun, 13 Apr 2025 17:37:02 +0000 (19:37 +0200)
committerDanilo Krummrich <dakr@kernel.org>
Thu, 17 Apr 2025 13:21:50 +0000 (15:21 +0200)
Require the Bound device context to be able to call iomap_region() and
iomap_region_sized(). Creating I/O mapping requires the device to be
bound.

Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20250413173758.12068-8-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
rust/kernel/pci.rs

index 1234b0c..3664d35 100644 (file)
@@ -390,7 +390,9 @@ impl Device {
         // - by its type invariant `self.as_raw` is always a valid pointer to a `struct pci_dev`.
         Ok(unsafe { bindings::pci_resource_len(self.as_raw(), bar.try_into()?) })
     }
+}
 
+impl Device<device::Bound> {
     /// Mapps an entire PCI-BAR after performing a region-request on it. I/O operation bound checks
     /// can be performed on compile time for offsets (plus the requested type size) < SIZE.
     pub fn iomap_region_sized<const SIZE: usize>(