mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-29 04:13:24 +00:00
Rename some misleading method names
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
cefeea7b50
commit
2bda8d17c4
@ -47,7 +47,7 @@ impl MmioBus {
|
||||
let length = self.common_devices.len();
|
||||
for i in (0..length).rev() {
|
||||
let common_device = self.common_devices.pop_front().unwrap();
|
||||
let device_id = common_device.device_id();
|
||||
let device_id = common_device.read_device_id().unwrap();
|
||||
let device = match driver.probe(common_device) {
|
||||
Ok(device) => {
|
||||
debug_assert!(device_id == device.device_id());
|
||||
@ -58,7 +58,6 @@ impl MmioBus {
|
||||
if err != BusProbeError::DeviceNotMatch {
|
||||
error!("MMIO device construction failed, reason: {:?}", err);
|
||||
}
|
||||
debug_assert!(device_id == device.device_id());
|
||||
device
|
||||
}
|
||||
};
|
||||
@ -68,7 +67,7 @@ impl MmioBus {
|
||||
}
|
||||
|
||||
pub(super) fn register_mmio_device(&mut self, mut mmio_device: MmioCommonDevice) {
|
||||
let device_id = mmio_device.device_id();
|
||||
let device_id = mmio_device.read_device_id().unwrap();
|
||||
for driver in self.drivers.iter() {
|
||||
mmio_device = match driver.probe(mmio_device) {
|
||||
Ok(device) => {
|
||||
@ -80,7 +79,6 @@ impl MmioBus {
|
||||
if err != BusProbeError::DeviceNotMatch {
|
||||
error!("MMIO device construction failed, reason: {:?}", err);
|
||||
}
|
||||
debug_assert!(device_id == common_device.device_id());
|
||||
common_device
|
||||
}
|
||||
};
|
||||
|
@ -10,6 +10,7 @@ use crate::{
|
||||
io_mem::IoMem,
|
||||
mm::{paddr_to_vaddr, Paddr, VmIoOnce},
|
||||
trap::IrqLine,
|
||||
Error, Result,
|
||||
};
|
||||
|
||||
/// MMIO Common device.
|
||||
@ -37,7 +38,7 @@ impl MmioCommonDevice {
|
||||
};
|
||||
info!(
|
||||
"[Virtio]: Found Virtio mmio device, device id:{:?}, irq number:{:?}",
|
||||
res.device_id(),
|
||||
res.read_device_id().unwrap(),
|
||||
res.irq.num()
|
||||
);
|
||||
res
|
||||
@ -54,13 +55,14 @@ impl MmioCommonDevice {
|
||||
}
|
||||
|
||||
/// Device ID
|
||||
pub fn device_id(&self) -> u32 {
|
||||
self.io_mem.read_once::<u32>(8).unwrap()
|
||||
pub fn read_device_id(&self) -> Result<u32> {
|
||||
self.io_mem.read_once::<u32>(8)
|
||||
}
|
||||
|
||||
/// Version of the MMIO device.
|
||||
pub fn version(&self) -> VirtioMmioVersion {
|
||||
VirtioMmioVersion::try_from(self.io_mem.read_once::<u32>(4).unwrap()).unwrap()
|
||||
pub fn read_version(&self) -> Result<VirtioMmioVersion> {
|
||||
VirtioMmioVersion::try_from(self.io_mem.read_once::<u32>(4)?)
|
||||
.map_err(|_| Error::InvalidArgs)
|
||||
}
|
||||
|
||||
/// Interrupt line
|
||||
|
Reference in New Issue
Block a user