Skip to content

Commit

Permalink
devices/virtio-serial: use DEFAULT_TIMEOUT const
Browse files Browse the repository at this point in the history
Signed-off-by: Jiaqi Gao <[email protected]>
  • Loading branch information
gaojiaqi7 committed Jan 8, 2024
1 parent 8846a53 commit 9d6b2fe
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/devices/virtio_serial/src/port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use rust_std_stub::io::{self, Read, Write};

use crate::{Result, VirtioSerialError, SERIAL_DEVICE};

const DEFAULT_TIMEOUT: u64 = 8000;

pub struct VirtioSerialPort {
port_id: u32,
cache: VecDeque<Vec<u8>>,
Expand Down Expand Up @@ -57,7 +59,7 @@ impl VirtioSerialPort {
.lock()
.get_mut()
.ok_or(VirtioSerialError::InvalidParameter)?
.enqueue(data, self.port_id, 0x8_0000)
.enqueue(data, self.port_id, DEFAULT_TIMEOUT)
}

pub fn recv(&mut self, data: &mut [u8]) -> Result<usize> {
Expand All @@ -66,7 +68,7 @@ impl VirtioSerialPort {
.lock()
.get_mut()
.ok_or(VirtioSerialError::InvalidParameter)?
.dequeue(self.port_id, 10000)?;
.dequeue(self.port_id, DEFAULT_TIMEOUT)?;
self.cache.push_back(recv_bytes);
}

Expand Down

0 comments on commit 9d6b2fe

Please sign in to comment.