From f3dc245c4fd1d603eb39164d14e2a6af47de0092 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Wed, 11 Mar 2020 09:25:26 +0100 Subject: [PATCH] pci: Extend PciDevice trait with new free_bars() method The point of this new method is to let the caller decide when the implementation of the PciDevice should free the BARs previously allocated through the other method allocate_bars(). This provides a way to perform proper cleanup for any PCI device. Signed-off-by: Sebastien Boeuf --- pci/src/device.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pci/src/device.rs b/pci/src/device.rs index 570043d36..efdd078a3 100755 --- a/pci/src/device.rs +++ b/pci/src/device.rs @@ -55,6 +55,11 @@ pub trait PciDevice: BusDevice { Ok(Vec::new()) } + /// Frees the PCI BARs previously allocated with a call to allocate_bars(). + fn free_bars(&mut self, _allocator: &mut SystemAllocator) -> Result<()> { + Ok(()) + } + /// Sets a register in the configuration space. /// * `reg_idx` - The index of the config register to modify. /// * `offset` - Offset in to the register.