pci: Accept MmioRegion reference in has_matching_slots()

Change has_matching_slots() to compare two MmioRegion instances
directly rather than requiring callers to construct an intermediate
HashSet of slot numbers. Remove the now-unused
user_memory_region_slots() method and HashSet import.

Signed-off-by: Damian Barabonkov <dbctl@pm.me>
This commit is contained in:
Damian Barabonkov 2026-02-10 12:23:28 -08:00 committed by Bo Chen
parent c2add07476
commit 638848fcff

View file

@ -276,6 +276,17 @@ pub struct MmioRegion {
pub(crate) user_memory_regions: Vec<UserMemoryRegion>, pub(crate) user_memory_regions: Vec<UserMemoryRegion>,
} }
impl MmioRegion {
/// Returns true if this region has the exact same memory slots as the other region.
pub fn has_matching_slots(&self, other: &MmioRegion) -> bool {
self.user_memory_regions.len() == other.user_memory_regions.len()
&& self
.user_memory_regions
.iter()
.all(|u| other.user_memory_regions.iter().any(|o| o.slot == u.slot))
}
}
/// # Safety /// # Safety
/// ///
/// [`Self::find_user_address`] must always either return `Err` /// [`Self::find_user_address`] must always either return `Err`