diff options
Diffstat (limited to 'devices')
-rw-r--r-- | devices/src/pci/pci_configuration.rs | 17 | ||||
-rw-r--r-- | devices/src/pci/vfio_pci.rs | 5 | ||||
-rw-r--r-- | devices/src/virtio/balloon.rs | 2 | ||||
-rw-r--r-- | devices/src/virtio/descriptor_utils.rs | 2 | ||||
-rw-r--r-- | devices/src/virtio/input/mod.rs | 2 | ||||
-rw-r--r-- | devices/src/virtio/rng.rs | 2 | ||||
-rw-r--r-- | devices/src/virtio/wl.rs | 13 |
7 files changed, 19 insertions, 24 deletions
diff --git a/devices/src/pci/pci_configuration.rs b/devices/src/pci/pci_configuration.rs index ebfa2a6..ff2da1a 100644 --- a/devices/src/pci/pci_configuration.rs +++ b/devices/src/pci/pci_configuration.rs @@ -25,7 +25,7 @@ const INTERRUPT_LINE_PIN_REG: usize = 15; /// Represents the types of PCI headers allowed in the configuration registers. #[allow(dead_code)] -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] pub enum PciHeaderType { Device, Bridge, @@ -33,7 +33,7 @@ pub enum PciHeaderType { /// Classes of PCI nodes. #[allow(dead_code)] -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] pub enum PciClassCode { TooOld, MassStorage, @@ -70,7 +70,7 @@ pub trait PciSubclass { /// Subclasses of the MultimediaController class. #[allow(dead_code)] -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum PciMultimediaSubclass { VideoController = 0x00, AudioController = 0x01, @@ -87,7 +87,7 @@ impl PciSubclass for PciMultimediaSubclass { /// Subclasses of the BridgeDevice #[allow(dead_code)] -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum PciBridgeSubclass { HostBridge = 0x00, IsaBridge = 0x01, @@ -111,7 +111,7 @@ impl PciSubclass for PciBridgeSubclass { /// Subclass of the SerialBus #[allow(dead_code)] -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum PciSerialBusSubClass { Firewire = 0x00, ACCESSbus = 0x01, @@ -135,6 +135,7 @@ pub trait PciProgrammingInterface { } /// Types of PCI capabilities. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum PciCapabilityID { ListID = 0, PowerManagement = 0x01, @@ -177,20 +178,20 @@ pub struct PciConfiguration { } /// See pci_regs.h in kernel -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum PciBarRegionType { Memory32BitRegion = 0, IORegion = 0x01, Memory64BitRegion = 0x04, } -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum PciBarPrefetchable { NotPrefetchable = 0, Prefetchable = 0x08, } -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] pub struct PciBarConfiguration { addr: u64, size: u64, diff --git a/devices/src/pci/vfio_pci.rs b/devices/src/pci/vfio_pci.rs index fa27dec..5f6998e 100644 --- a/devices/src/pci/vfio_pci.rs +++ b/devices/src/pci/vfio_pci.rs @@ -832,10 +832,7 @@ impl PciDevice for VfioPciDevice { low = self.config.read_config_dword(offset); let low_flag = low & 0xf; - let is_64bit = match low_flag & 0x4 { - 0x4 => true, - _ => false, - }; + let is_64bit = (low_flag & 0x4) == 0x4; if (low_flag & 0x1 == 0 || i == VFIO_PCI_ROM_REGION_INDEX) && low != 0 { let mut upper: u32 = 0xffffffff; if is_64bit { diff --git a/devices/src/virtio/balloon.rs b/devices/src/virtio/balloon.rs index 30417fa..b549258 100644 --- a/devices/src/virtio/balloon.rs +++ b/devices/src/virtio/balloon.rs @@ -28,7 +28,7 @@ pub enum BalloonError { /// Failure wriitng the config notification event. WritingConfigEvent(sys_util::Error), } -pub type Result<T> = std::result::Result<T, BalloonError>; +type Result<T> = std::result::Result<T, BalloonError>; impl Display for BalloonError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/devices/src/virtio/descriptor_utils.rs b/devices/src/virtio/descriptor_utils.rs index c878a45..902e3c3 100644 --- a/devices/src/virtio/descriptor_utils.rs +++ b/devices/src/virtio/descriptor_utils.rs @@ -46,7 +46,7 @@ impl Display for Error { } } -pub type Result<T> = result::Result<T, Error>; +type Result<T> = result::Result<T, Error>; impl std::error::Error for Error {} diff --git a/devices/src/virtio/input/mod.rs b/devices/src/virtio/input/mod.rs index c789dd8..452a003 100644 --- a/devices/src/virtio/input/mod.rs +++ b/devices/src/virtio/input/mod.rs @@ -61,7 +61,7 @@ pub enum InputError { WriteQueue(std::io::Error), } -pub type Result<T> = std::result::Result<T, InputError>; +type Result<T> = std::result::Result<T, InputError>; impl Display for InputError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/devices/src/virtio/rng.rs b/devices/src/virtio/rng.rs index 3d7801f..3897ee3 100644 --- a/devices/src/virtio/rng.rs +++ b/devices/src/virtio/rng.rs @@ -20,7 +20,7 @@ pub enum RngError { /// Can't access /dev/urandom AccessingRandomDev(io::Error), } -pub type Result<T> = std::result::Result<T, RngError>; +type Result<T> = std::result::Result<T, RngError>; impl Display for RngError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/devices/src/virtio/wl.rs b/devices/src/virtio/wl.rs index 3a5ecee..6fefd51 100644 --- a/devices/src/virtio/wl.rs +++ b/devices/src/virtio/wl.rs @@ -28,7 +28,6 @@ //! the virtio queue, and routing messages in and out of `WlState`. Possible events include the kill //! event, available descriptors on the `in` or `out` queue, and incoming data on any vfd's socket. -use std::cell::RefCell; use std::collections::btree_map::Entry; use std::collections::{BTreeMap as Map, BTreeSet as Set, VecDeque}; use std::convert::From; @@ -327,21 +326,19 @@ impl From<VolatileMemoryError> for WlError { #[derive(Clone)] struct VmRequester { - inner: Rc<RefCell<VmMemoryControlRequestSocket>>, + vm_socket: Rc<VmMemoryControlRequestSocket>, } impl VmRequester { fn new(vm_socket: VmMemoryControlRequestSocket) -> VmRequester { VmRequester { - inner: Rc::new(RefCell::new(vm_socket)), + vm_socket: Rc::new(vm_socket), } } fn request(&self, request: VmMemoryRequest) -> WlResult<VmMemoryResponse> { - let mut inner = self.inner.borrow_mut(); - let vm_socket = &mut *inner; - vm_socket.send(&request).map_err(WlError::VmControl)?; - vm_socket.recv().map_err(WlError::VmControl) + self.vm_socket.send(&request).map_err(WlError::VmControl)?; + self.vm_socket.recv().map_err(WlError::VmControl) } } @@ -1252,7 +1249,7 @@ impl WlState { self.new_context(ctrl.id.into(), name) } op_type => { - warn!("unexpected command {}", op_type); + warn!("unexpected command {:#x}", op_type); Ok(WlResp::InvalidCommand) } } |