forked from AbleOS/ableos_userland
removing unnecessary unsafe{}
This commit is contained in:
parent
dc1331ba98
commit
3ff38b9e60
|
@ -160,9 +160,7 @@ impl Mouse {
|
||||||
self.write_command_port(DISABLE_SECOND)?;
|
self.write_command_port(DISABLE_SECOND)?;
|
||||||
|
|
||||||
// Flush output buffer: if the controller had anything to say, ignore it
|
// 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...");
|
debug!("mouse driver: writing GET_STATUS to port...");
|
||||||
self.write_command_port(GET_STATUS_BYTE)?;
|
self.write_command_port(GET_STATUS_BYTE)?;
|
||||||
|
@ -184,9 +182,7 @@ impl Mouse {
|
||||||
self.write_command_port(ENABLE_SECOND)?;
|
self.write_command_port(ENABLE_SECOND)?;
|
||||||
|
|
||||||
// Some keyboards actually send a reply, flush it
|
// Some keyboards actually send a reply, flush it
|
||||||
unsafe {
|
|
||||||
self.data_port.read();
|
self.data_port.read();
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -245,7 +241,7 @@ impl Mouse {
|
||||||
self.wait_for_read()?;
|
self.wait_for_read()?;
|
||||||
// HERESY: Stop
|
// HERESY: Stop
|
||||||
debug!("what's this");
|
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> {
|
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> {
|
fn write_command_port(&mut self, value: u8) -> Result<(), &'static str> {
|
||||||
debug!("mouse driver: waiting for write");
|
debug!("mouse driver: waiting for write");
|
||||||
self.wait_for_write()?;
|
self.wait_for_write()?;
|
||||||
unsafe {
|
|
||||||
self.command_port.write(value);
|
self.command_port.write(value);
|
||||||
}
|
|
||||||
debug!("mouse driver: command written");
|
debug!("mouse driver: command written");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_data_port(&mut self, value: u8) -> Result<(), &'static str> {
|
fn write_data_port(&mut self, value: u8) -> Result<(), &'static str> {
|
||||||
self.wait_for_write()?;
|
self.wait_for_write()?;
|
||||||
unsafe {
|
|
||||||
self.data_port.write(value);
|
self.data_port.write(value);
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wait_for_read(&mut self) -> Result<(), &'static str> {
|
fn wait_for_read(&mut self) -> Result<(), &'static str> {
|
||||||
let timeout = 100_000;
|
let timeout = 100_000;
|
||||||
for _x in 0..timeout {
|
for _x in 0..timeout {
|
||||||
let value = unsafe { self.command_port.read() };
|
let value = self.command_port.read();
|
||||||
if (value & 0x1) == 0x1 {
|
if (value & 0x1) == 0x1 {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
@ -293,7 +285,7 @@ impl Mouse {
|
||||||
fn wait_for_write(&mut self) -> Result<(), &'static str> {
|
fn wait_for_write(&mut self) -> Result<(), &'static str> {
|
||||||
let timeout = 100_000;
|
let timeout = 100_000;
|
||||||
for _ in 0..timeout {
|
for _ in 0..timeout {
|
||||||
let value = unsafe { self.command_port.read() };
|
let value = self.command_port.read();
|
||||||
if (value & 0x2) == 0x0 {
|
if (value & 0x2) == 0x0 {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue