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 <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2020-03-06 15:21:18 +01:00 committed by Rob Bradford
parent 08604ac6a8
commit f8e2008e0e

View File

@ -124,6 +124,11 @@ impl PciBus {
Ok(())
}
pub fn remove_by_device(&mut self, device: &Arc<Mutex<dyn PciDevice>>) -> Result<()> {
self.devices.retain(|dev| !Arc::ptr_eq(dev, device));
Ok(())
}
pub fn next_device_id(&self) -> u32 {
self.devices.len() as u32
}