From 90e8e074cdf1633b7136dcf44b8618df661e2315 Mon Sep 17 00:00:00 2001 From: Stephan Maka Date: Wed, 28 Aug 2019 22:46:00 +0200 Subject: [PATCH] firmware: turn errors into &str for remote_i2c as well should resolve breakage on a few targets/variants introduced by PR #1351 --- artiq/firmware/runtime/kern_hwreq.rs | 40 ++++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/artiq/firmware/runtime/kern_hwreq.rs b/artiq/firmware/runtime/kern_hwreq.rs index 008a3e9ec..d039d7ce2 100644 --- a/artiq/firmware/runtime/kern_hwreq.rs +++ b/artiq/firmware/runtime/kern_hwreq.rs @@ -14,67 +14,67 @@ mod remote_i2c { use rtio_mgt::drtio; use sched::{Io, Mutex}; - pub fn start(io: &Io, aux_mutex: &Mutex, linkno: u8, destination: u8, busno: u8) -> Result<(), ()> { + pub fn start(io: &Io, aux_mutex: &Mutex, linkno: u8, destination: u8, busno: u8) -> Result<(), &'static str> { let reply = drtio::aux_transact(io, aux_mutex, linkno, &drtioaux::Packet::I2cStartRequest { destination: destination, busno: busno }); match reply { Ok(drtioaux::Packet::I2cBasicReply { succeeded }) => { - if succeeded { Ok(()) } else { Err(()) } + if succeeded { Ok(()) } else { Err("i2c basic reply error") } } Ok(packet) => { error!("received unexpected aux packet: {:?}", packet); - Err(()) + Err("received unexpected aux packet") } Err(e) => { error!("aux packet error ({})", e); - Err(()) + Err(e) } } } - pub fn restart(io: &Io, aux_mutex: &Mutex, linkno: u8, destination: u8, busno: u8) -> Result<(), ()> { + pub fn restart(io: &Io, aux_mutex: &Mutex, linkno: u8, destination: u8, busno: u8) -> Result<(), &'static str> { let reply = drtio::aux_transact(io, aux_mutex, linkno, &drtioaux::Packet::I2cRestartRequest { destination: destination, busno: busno }); match reply { Ok(drtioaux::Packet::I2cBasicReply { succeeded }) => { - if succeeded { Ok(()) } else { Err(()) } + if succeeded { Ok(()) } else { Err("i2c basic reply error") } } Ok(packet) => { error!("received unexpected aux packet: {:?}", packet); - Err(()) + Err("received unexpected aux packet") } Err(e) => { error!("aux packet error ({})", e); - Err(()) + Err(e) } } } - pub fn stop(io: &Io, aux_mutex: &Mutex, linkno: u8, destination: u8, busno: u8) -> Result<(), ()> { + pub fn stop(io: &Io, aux_mutex: &Mutex, linkno: u8, destination: u8, busno: u8) -> Result<(), &'static str> { let reply = drtio::aux_transact(io, aux_mutex, linkno, &drtioaux::Packet::I2cStopRequest { destination: destination, busno: busno }); match reply { Ok(drtioaux::Packet::I2cBasicReply { succeeded }) => { - if succeeded { Ok(()) } else { Err(()) } + if succeeded { Ok(()) } else { Err("i2c basic reply error") } } Ok(packet) => { error!("received unexpected aux packet: {:?}", packet); - Err(()) + Err("received unexpected aux packet") } Err(e) => { error!("aux packet error ({})", e); - Err(()) + Err(e) } } } - pub fn write(io: &Io, aux_mutex: &Mutex, linkno: u8, destination: u8, busno: u8, data: u8) -> Result { + pub fn write(io: &Io, aux_mutex: &Mutex, linkno: u8, destination: u8, busno: u8, data: u8) -> Result { let reply = drtio::aux_transact(io, aux_mutex, linkno, &drtioaux::Packet::I2cWriteRequest { destination: destination, busno: busno, @@ -82,20 +82,20 @@ mod remote_i2c { }); match reply { Ok(drtioaux::Packet::I2cWriteReply { succeeded, ack }) => { - if succeeded { Ok(ack) } else { Err(()) } + if succeeded { Ok(ack) } else { Err("i2c write reply error") } } Ok(_) => { error!("received unexpected aux packet"); - Err(()) + Err("received unexpected aux packet") } Err(e) => { error!("aux packet error ({})", e); - Err(()) + Err(e) } } } - pub fn read(io: &Io, aux_mutex: &Mutex, linkno: u8, destination: u8, busno: u8, ack: bool) -> Result { + pub fn read(io: &Io, aux_mutex: &Mutex, linkno: u8, destination: u8, busno: u8, ack: bool) -> Result { let reply = drtio::aux_transact(io, aux_mutex, linkno, &drtioaux::Packet::I2cReadRequest { destination: destination, busno: busno, @@ -103,15 +103,15 @@ mod remote_i2c { }); match reply { Ok(drtioaux::Packet::I2cReadReply { succeeded, data }) => { - if succeeded { Ok(data) } else { Err(()) } + if succeeded { Ok(data) } else { Err("i2c read reply error") } } Ok(_) => { error!("received unexpected aux packet"); - Err(()) + Err("received unexpected aux packet") } Err(e) => { error!("aux packet error ({})", e); - Err(()) + Err(e) } } }