From f57d970451fe65fddf68834cf1aa1e70322455c5 Mon Sep 17 00:00:00 2001 From: Michael Zhao Date: Tue, 21 Jul 2020 19:51:09 +0800 Subject: [PATCH] arch: Code cleanup after refactoring aarch64 Signed-off-by: Michael Zhao --- arch/src/aarch64/gic.rs | 38 +++++++++-------------------------- arch/src/aarch64/gicv2.rs | 6 +++--- arch/src/aarch64/gicv3.rs | 6 +++--- arch/src/aarch64/gicv3_its.rs | 8 ++++---- 4 files changed, 20 insertions(+), 38 deletions(-) diff --git a/arch/src/aarch64/gic.rs b/arch/src/aarch64/gic.rs index 93ad1f4bf..601d6e893 100644 --- a/arch/src/aarch64/gic.rs +++ b/arch/src/aarch64/gic.rs @@ -47,11 +47,11 @@ pub trait GICDevice { } pub mod kvm { - use super::super::gicv2::kvm::KvmGICv2; - use super::super::gicv3::kvm::KvmGICv3; - use super::super::gicv3_its::kvm::KvmGICv3ITS; use super::GICDevice; use super::Result; + use crate::aarch64::gicv2::kvm::KvmGICv2; + use crate::aarch64::gicv3::kvm::KvmGICv3; + use crate::aarch64::gicv3_its::kvm::KvmGICv3ITS; use crate::layout; use hypervisor::kvm::kvm_bindings; use std::boxed::Box; @@ -60,31 +60,22 @@ pub mod kvm { /// Trait for GIC devices. pub trait KvmGICDevice: Send + Sync + GICDevice { /// Returns the GIC version of the device - fn version() -> u32 - where - Self: Sized; + fn version() -> u32; /// Create the GIC device object fn create_device( device: Arc, vcpu_count: u64, - ) -> Box - where - Self: Sized; + ) -> Box; /// Setup the device-specific attributes fn init_device_attributes( vm: &Arc, gic_device: &Box, - ) -> Result<()> - where - Self: Sized; + ) -> Result<()>; /// Initialize a GIC device - fn init_device(vm: &Arc) -> Result> - where - Self: Sized, - { + fn init_device(vm: &Arc) -> Result> { let mut gic_device = kvm_bindings::kvm_create_device { type_: Self::version(), fd: 0, @@ -102,10 +93,7 @@ pub mod kvm { attr: u64, addr: u64, flags: u32, - ) -> Result<()> - where - Self: Sized, - { + ) -> Result<()> { let attr = kvm_bindings::kvm_device_attr { group: group, attr: attr, @@ -120,10 +108,7 @@ pub mod kvm { } /// Finalize the setup of a GIC device - fn finalize_device(gic_device: &Box) -> Result<()> - where - Self: Sized, - { + fn finalize_device(gic_device: &Box) -> Result<()> { /* We need to tell the kernel how many irqs to support with this vgic. * See the `layout` module for details. */ @@ -152,10 +137,7 @@ pub mod kvm { } /// Method to initialize the GIC device - fn new(vm: &Arc, vcpu_count: u64) -> Result> - where - Self: Sized, - { + fn new(vm: &Arc, vcpu_count: u64) -> Result> { let vgic_fd = Self::init_device(vm)?; let device = Self::create_device(vgic_fd, vcpu_count); diff --git a/arch/src/aarch64/gicv2.rs b/arch/src/aarch64/gicv2.rs index 612e87d79..e840fd3f5 100644 --- a/arch/src/aarch64/gicv2.rs +++ b/arch/src/aarch64/gicv2.rs @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 pub mod kvm { - use super::super::gic::kvm::KvmGICDevice; - use super::super::gic::{Error, GICDevice}; + use crate::aarch64::gic::kvm::KvmGICDevice; + use crate::aarch64::gic::{Error, GICDevice}; use std::{boxed::Box, result}; type Result = result::Result; use crate::layout; @@ -12,7 +12,7 @@ pub mod kvm { /// Represent a GIC v2 device pub struct KvmGICv2 { - /// The file descriptor for the KVM device + /// The hypervisor agnostic device device: Arc, /// GIC device properties, to be used for setting up the fdt entry diff --git a/arch/src/aarch64/gicv3.rs b/arch/src/aarch64/gicv3.rs index bfb49f737..f7673eef7 100644 --- a/arch/src/aarch64/gicv3.rs +++ b/arch/src/aarch64/gicv3.rs @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 pub mod kvm { - use super::super::gic::kvm::KvmGICDevice; - use super::super::gic::{Error, GICDevice}; + use crate::aarch64::gic::kvm::KvmGICDevice; + use crate::aarch64::gic::{Error, GICDevice}; use crate::layout; use hypervisor::kvm::kvm_bindings; use std::sync::Arc; @@ -11,7 +11,7 @@ pub mod kvm { type Result = result::Result; pub struct KvmGICv3 { - /// The file descriptor for the KVM device + /// The hypervisor agnostic device device: Arc, /// GIC device properties, to be used for setting up the fdt entry diff --git a/arch/src/aarch64/gicv3_its.rs b/arch/src/aarch64/gicv3_its.rs index e66248028..9967433fd 100644 --- a/arch/src/aarch64/gicv3_its.rs +++ b/arch/src/aarch64/gicv3_its.rs @@ -5,13 +5,13 @@ pub mod kvm { use std::sync::Arc; use std::{boxed::Box, result}; type Result = result::Result; - use super::super::gic::kvm::KvmGICDevice; - use super::super::gic::{Error, GICDevice}; - use super::super::gicv3::kvm::KvmGICv3; + use crate::aarch64::gic::kvm::KvmGICDevice; + use crate::aarch64::gic::{Error, GICDevice}; + use crate::aarch64::gicv3::kvm::KvmGICv3; use hypervisor::kvm::kvm_bindings; pub struct KvmGICv3ITS { - /// The file descriptor for the KVM device + /// The hypervisor agnostic device device: Arc, /// GIC device properties, to be used for setting up the fdt entry