Fix #[allow(dead_code)] in virtio

This commit is contained in:
Ruihan Li 2025-01-24 17:38:05 +08:00 committed by Tate, Hongliang Tian
parent b415538097
commit 1c4e88e648
9 changed files with 9 additions and 24 deletions

View File

@ -63,6 +63,7 @@ impl ConfigManager<VirtioConsoleConfig> {
/// If `VIRTIO_CONSOLE_F_EMERG_WRITE` is supported then the driver can
/// use emergency write to output a single character without initializing
/// virtio queues, or even acknowledging the feature.
#[expect(dead_code)]
pub(super) fn emerg_write(&self, value: u32) {
if self.is_modern() {
self.write_once(offset_of!(VirtioConsoleConfig, emerg_wr), value)

View File

@ -84,6 +84,7 @@ impl VirtioInputConfig {
#[repr(C)]
#[derive(Debug, Copy, Clone, Pod)]
#[expect(dead_code)]
struct AbsInfo {
min: u32,
max: u32,
@ -94,6 +95,7 @@ struct AbsInfo {
#[repr(C)]
#[derive(Debug, Copy, Clone, Pod)]
#[expect(dead_code)]
struct DevIds {
bustype: u16,
vendor: u16,

View File

@ -10,7 +10,6 @@ use ostd::{
use spin::Once;
const RX_BUFFER_LEN: usize = 4096;
const TX_BUFFER_LEN: usize = 4096;
pub static RX_BUFFER_POOL: Once<Arc<DmaPool>> = Once::new();
pub static TX_BUFFER_POOL: Once<SpinLock<LinkedList<DmaStream>, LocalIrqDisabled>> = Once::new();

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MPL-2.0
use alloc::{boxed::Box, string::ToString, sync::Arc, vec, vec::Vec};
use alloc::{boxed::Box, string::ToString, sync::Arc, vec};
use core::{fmt::Debug, hint::spin_loop, mem::size_of};
use aster_network::{RxBuffer, TxBuffer};
@ -13,7 +13,6 @@ use super::{
connect::{ConnectionInfo, VsockEvent},
error::SocketError,
header::{VirtioVsockHdr, VirtioVsockOp, VIRTIO_VSOCK_HDR_LEN},
VsockDeviceIrqHandler,
};
use crate::{
device::{
@ -44,7 +43,6 @@ pub struct SocketDevice {
rx_buffers: SlotVec<RxBuffer>,
transport: Box<dyn VirtioTransport>,
callbacks: Vec<Box<dyn VsockDeviceIrqHandler>>,
}
impl SocketDevice {
@ -90,7 +88,6 @@ impl SocketDevice {
event_queue,
rx_buffers,
transport,
callbacks: Vec::new(),
};
// Interrupt handler if vsock device config space changes

View File

@ -3,7 +3,6 @@
//! The virtio of Asterinas.
#![no_std]
#![deny(unsafe_code)]
#![allow(dead_code)]
#![feature(trait_alias)]
#![feature(fn_traits)]
#![feature(linked_list_cursors)]

View File

@ -21,10 +21,6 @@ pub struct VirtioMmioDriver {
}
impl VirtioMmioDriver {
pub fn num_devices(&self) -> usize {
self.devices.lock().len()
}
pub fn pop_device_transport(&self) -> Option<VirtioMmioTransport> {
self.devices.lock().pop()
}

View File

@ -2,9 +2,10 @@
use alloc::sync::Arc;
use log::warn;
use ostd::bus::pci::{
capability::vendor::CapabilityVndrData,
cfg_space::{Bar, IoBar, MemoryBar},
cfg_space::{Bar, MemoryBar},
common_device::BarManager,
};
@ -26,7 +27,6 @@ pub struct VirtioPciCapabilityData {
length: u32,
option: Option<u32>,
memory_bar: Option<Arc<MemoryBar>>,
io_bar: Option<Arc<IoBar>>,
}
impl VirtioPciCapabilityData {
@ -34,10 +34,6 @@ impl VirtioPciCapabilityData {
&self.memory_bar
}
pub fn io_bar(&self) -> &Option<Arc<IoBar>> {
&self.io_bar
}
pub fn offset(&self) -> u32 {
self.offset
}
@ -74,15 +70,14 @@ impl VirtioPciCapabilityData {
None
};
let mut io_bar = None;
let mut memory_bar = None;
if let Some(bar) = bar_manager.bar(bar) {
match bar {
Bar::Memory(memory) => {
memory_bar = Some(memory);
}
Bar::Io(io) => {
io_bar = Some(io);
Bar::Io(_) => {
warn!("`Bar::Io` is not supported")
}
}
};
@ -92,7 +87,6 @@ impl VirtioPciCapabilityData {
length,
option,
memory_bar,
io_bar,
}
}
}

View File

@ -25,10 +25,6 @@ pub struct VirtioPciDriver {
}
impl VirtioPciDriver {
pub fn num_devices(&self) -> usize {
self.devices.lock().len()
}
pub fn pop_device_transport(&self) -> Option<Box<dyn VirtioTransport>> {
self.devices.lock().pop()
}

View File

@ -53,6 +53,7 @@ const QUEUE_SIZE_OFFSET: usize = 0x0c;
const QUEUE_SELECT_OFFSET: usize = 0x0e;
const QUEUE_NOTIFY_OFFSET: usize = 0x10;
const DEVICE_STATUS_OFFSET: usize = 0x12;
#[expect(dead_code)]
const ISR_STATUS_OFFSET: usize = 0x13;
// If MSI-X is enabled for the device, there are two additional fields.
const CONFIG_MSIX_VECTOR_OFFSET: usize = 0x14;