libs: Prepare libhyp for move
Trivial changes to limit the diff when moving the files to a minimum:
- use the relative super::hypervisor path in the (private) back-ends;
- get Error and Result directly from crate:: (not crate::error::);
- move extern crate alloc next to cfg(no_std) (can be removed at once);
- remove (private i.e. unused) "use hypervisor::GeniezoneError"
Test: -
Change-Id: I55f5c74d0e6fc78eeb5d066174816a60bb10936c
diff --git a/libs/hyp/src/error.rs b/libs/hyp/src/error.rs
index 3fdad70..bbf706e 100644
--- a/libs/hyp/src/error.rs
+++ b/libs/hyp/src/error.rs
@@ -14,9 +14,9 @@
//! Error and Result types for hypervisor.
-use crate::GeniezoneError;
-use crate::KvmError;
use core::{fmt, result};
+
+use super::hypervisor::{GeniezoneError, KvmError};
use uuid::Uuid;
/// Result type with hypervisor error.
diff --git a/libs/hyp/src/hypervisor.rs b/libs/hyp/src/hypervisor.rs
index c53b886..dab15ec 100644
--- a/libs/hyp/src/hypervisor.rs
+++ b/libs/hyp/src/hypervisor.rs
@@ -14,14 +14,12 @@
//! Wrappers around hypervisor back-ends.
-extern crate alloc;
-
mod common;
mod geniezone;
mod gunyah;
mod kvm;
-use crate::error::{Error, Result};
+use super::{Error, Result};
use alloc::boxed::Box;
use common::Hypervisor;
pub use common::{
diff --git a/libs/hyp/src/hypervisor/common.rs b/libs/hyp/src/hypervisor/common.rs
index eaac652..f4973e5 100644
--- a/libs/hyp/src/hypervisor/common.rs
+++ b/libs/hyp/src/hypervisor/common.rs
@@ -14,8 +14,7 @@
//! This module regroups some common traits shared by all the hypervisors.
-use crate::error::{Error, Result};
-use crate::util::SIZE_4KB;
+use crate::{util::SIZE_4KB, Error, Result};
/// Expected MMIO guard granule size, validated during MMIO guard initialization.
pub const MMIO_GUARD_GRANULE_SIZE: usize = SIZE_4KB;
diff --git a/libs/hyp/src/hypervisor/geniezone.rs b/libs/hyp/src/hypervisor/geniezone.rs
index ad18e17..86e5361 100644
--- a/libs/hyp/src/hypervisor/geniezone.rs
+++ b/libs/hyp/src/hypervisor/geniezone.rs
@@ -14,10 +14,11 @@
//! Wrappers around calls to the GenieZone hypervisor.
-use super::common::{Hypervisor, MemSharingHypervisor, MmioGuardedHypervisor};
-use crate::error::{Error, Result};
-use crate::util::page_address;
use core::fmt::{self, Display, Formatter};
+
+use super::{Hypervisor, MemSharingHypervisor, MmioGuardedHypervisor};
+use crate::{util::page_address, Error, Result};
+
use smccc::{
error::{positive_or_error_64, success_or_error_64},
hvc64,
diff --git a/libs/hyp/src/hypervisor/kvm.rs b/libs/hyp/src/hypervisor/kvm.rs
index 720318e..c0cafbe 100644
--- a/libs/hyp/src/hypervisor/kvm.rs
+++ b/libs/hyp/src/hypervisor/kvm.rs
@@ -14,12 +14,11 @@
//! Wrappers around calls to the KVM hypervisor.
-use super::common::{
- DeviceAssigningHypervisor, Hypervisor, MemSharingHypervisor, MmioGuardedHypervisor,
-};
-use crate::error::{Error, Result};
-use crate::util::page_address;
use core::fmt::{self, Display, Formatter};
+
+use super::{DeviceAssigningHypervisor, Hypervisor, MemSharingHypervisor, MmioGuardedHypervisor};
+use crate::{util::page_address, Error, Result};
+
use smccc::{
error::{positive_or_error_64, success_or_error_32, success_or_error_64},
hvc64,
diff --git a/libs/hyp/src/lib.rs b/libs/hyp/src/lib.rs
index 6a23585..2e19bbc 100644
--- a/libs/hyp/src/lib.rs
+++ b/libs/hyp/src/lib.rs
@@ -16,14 +16,14 @@
#![no_std]
+extern crate alloc;
+
mod error;
mod hypervisor;
mod util;
-pub use crate::hypervisor::DeviceAssigningHypervisor;
pub use error::{Error, Result};
pub use hypervisor::{
- get_device_assigner, get_mem_sharer, get_mmio_guard, KvmError, MMIO_GUARD_GRANULE_SIZE,
+ get_device_assigner, get_mem_sharer, get_mmio_guard, DeviceAssigningHypervisor, KvmError,
+ MMIO_GUARD_GRANULE_SIZE,
};
-
-use hypervisor::GeniezoneError;