tool: Use From<T> for slightly neater error handling
This commit is contained in:
committed by
Jeremy Soller
parent
43d31ca0c3
commit
802bf417cc
@@ -111,8 +111,8 @@ impl AccessLpcLinux {
|
||||
)));
|
||||
}
|
||||
|
||||
let cmd = PortLock::new(SMFI_CMD_BASE, SMFI_CMD_BASE + SMFI_CMD_SIZE as u16 - 1).map_err(Error::Io)?;
|
||||
let dbg = PortLock::new(SMFI_DBG_BASE, SMFI_DBG_BASE + SMFI_DBG_SIZE as u16 - 1).map_err(Error::Io)?;
|
||||
let cmd = PortLock::new(SMFI_CMD_BASE, SMFI_CMD_BASE + SMFI_CMD_SIZE as u16 - 1)?;
|
||||
let dbg = PortLock::new(SMFI_DBG_BASE, SMFI_DBG_BASE + SMFI_DBG_SIZE as u16 - 1)?;
|
||||
Ok(Self {
|
||||
cmd,
|
||||
dbg,
|
||||
@@ -122,18 +122,18 @@ impl AccessLpcLinux {
|
||||
|
||||
/// Read from the command space
|
||||
unsafe fn read_cmd(&mut self, addr: u8) -> Result<u8, Error> {
|
||||
self.cmd.read(addr as u16).map_err(Error::Io)
|
||||
Ok(self.cmd.read(addr as u16)?)
|
||||
}
|
||||
|
||||
/// Write to the command space
|
||||
unsafe fn write_cmd(&mut self, addr: u8, data: u8) -> Result<(), Error> {
|
||||
self.cmd.write(addr as u16, data).map_err(Error::Io)
|
||||
Ok(self.cmd.write(addr as u16, data)?)
|
||||
}
|
||||
|
||||
/// Read from the debug space
|
||||
//TODO: better public interface
|
||||
pub unsafe fn read_debug(&mut self, addr: u8) -> Result<u8, Error> {
|
||||
self.dbg.read(addr as u16).map_err(Error::Io)
|
||||
Ok(self.dbg.read(addr as u16)?)
|
||||
}
|
||||
|
||||
/// Returns Ok if a command can be sent
|
||||
|
Reference in New Issue
Block a user