removing unnecessary unsafe{}

master
Able 2023-03-09 04:56:57 -06:00
parent 10381f18ac
commit 5b790abd79
1 changed files with 7 additions and 15 deletions

View File

@ -160,9 +160,7 @@ impl Mouse {
self.write_command_port(DISABLE_SECOND)?;
// Flush output buffer: if the controller had anything to say, ignore it
unsafe {
self.data_port.read();
}
self.data_port.read();
debug!("mouse driver: writing GET_STATUS to port...");
self.write_command_port(GET_STATUS_BYTE)?;
@ -184,9 +182,7 @@ impl Mouse {
self.write_command_port(ENABLE_SECOND)?;
// Some keyboards actually send a reply, flush it
unsafe {
self.data_port.read();
}
self.data_port.read();
Ok(())
}
@ -245,7 +241,7 @@ impl Mouse {
self.wait_for_read()?;
// HERESY: Stop
debug!("what's this");
Ok(unsafe { self.data_port.read() })
Ok(self.data_port.read())
}
fn send_command(&mut self, command: Command) -> Result<(), &'static str> {
@ -264,25 +260,21 @@ impl Mouse {
fn write_command_port(&mut self, value: u8) -> Result<(), &'static str> {
debug!("mouse driver: waiting for write");
self.wait_for_write()?;
unsafe {
self.command_port.write(value);
}
self.command_port.write(value);
debug!("mouse driver: command written");
Ok(())
}
fn write_data_port(&mut self, value: u8) -> Result<(), &'static str> {
self.wait_for_write()?;
unsafe {
self.data_port.write(value);
}
self.data_port.write(value);
Ok(())
}
fn wait_for_read(&mut self) -> Result<(), &'static str> {
let timeout = 100_000;
for _x in 0..timeout {
let value = unsafe { self.command_port.read() };
let value = self.command_port.read();
if (value & 0x1) == 0x1 {
return Ok(());
}
@ -293,7 +285,7 @@ impl Mouse {
fn wait_for_write(&mut self) -> Result<(), &'static str> {
let timeout = 100_000;
for _ in 0..timeout {
let value = unsafe { self.command_port.read() };
let value = self.command_port.read();
if (value & 0x2) == 0x0 {
return Ok(());
}