pvmfw: smccc: Introduce smccc::Result<>
Test: -
Change-Id: I8396373827a93a0a610936c5882d6f03256b9258
diff --git a/pvmfw/src/smccc.rs b/pvmfw/src/smccc.rs
index e3a2b05..d610c70 100644
--- a/pvmfw/src/smccc.rs
+++ b/pvmfw/src/smccc.rs
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-use core::fmt;
+use core::{fmt, result};
// TODO(b/245889995): use psci-0.1.1 crate
#[inline(always)]
@@ -75,14 +75,16 @@
}
}
-fn check_smccc_err(ret: i64) -> Result<(), Error> {
+type Result<T> = result::Result<T, Error>;
+
+fn check_smccc_err(ret: i64) -> Result<()> {
match check_smccc_value(ret)? {
0 => Ok(()),
v => Err(Error::Unexpected(v)),
}
}
-fn check_smccc_value(ret: i64) -> Result<u64, Error> {
+fn check_smccc_value(ret: i64) -> Result<u64> {
match ret {
x if x >= 0 => Ok(ret as u64),
-1 => Err(Error::NotSupported),
@@ -96,7 +98,7 @@
const VENDOR_HYP_KVM_MMIO_GUARD_MAP_FUNC_ID: u32 = 0xc6000007;
/// Issue pKVM-specific MMIO_GUARD_INFO HVC64.
-pub fn mmio_guard_info() -> Result<u64, Error> {
+pub fn mmio_guard_info() -> Result<u64> {
let args = [0u64; 17];
let res = hvc64(VENDOR_HYP_KVM_MMIO_GUARD_INFO_FUNC_ID, args);
@@ -105,7 +107,7 @@
}
/// Issue pKVM-specific MMIO_GUARD_MAP HVC64.
-pub fn mmio_guard_map(ipa: u64) -> Result<(), Error> {
+pub fn mmio_guard_map(ipa: u64) -> Result<()> {
let mut args = [0u64; 17];
args[0] = ipa;