From f8e2008e0e10cdbbe9938b2779bceb4283b8a6fe Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Fri, 6 Mar 2020 15:21:18 +0100 Subject: [PATCH] pci: Add a function to remove a PciDevice from the bus Simple function relying on the retain() method from std::Vec, allowing to remove every occurence of the same device. Signed-off-by: Sebastien Boeuf --- pci/src/bus.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pci/src/bus.rs b/pci/src/bus.rs index 3ee9a3402..7c7fa61d1 100644 --- a/pci/src/bus.rs +++ b/pci/src/bus.rs @@ -124,6 +124,11 @@ impl PciBus { Ok(()) } + pub fn remove_by_device(&mut self, device: &Arc>) -> Result<()> { + self.devices.retain(|dev| !Arc::ptr_eq(dev, device)); + Ok(()) + } + pub fn next_device_id(&self) -> u32 { self.devices.len() as u32 }