From 3ff38b9e6060b379115a66d312de9b6301ca600a Mon Sep 17 00:00:00 2001 From: Able Date: Thu, 9 Mar 2023 04:56:57 -0600 Subject: [PATCH] removing unnecessary unsafe{} --- drivers/mice/ps2_mouse/src/main.rs | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/drivers/mice/ps2_mouse/src/main.rs b/drivers/mice/ps2_mouse/src/main.rs index c174b7c..21be4dc 100644 --- a/drivers/mice/ps2_mouse/src/main.rs +++ b/drivers/mice/ps2_mouse/src/main.rs @@ -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(()); }