Skip to content

Commit

Permalink
capsules: i2c_master: Relay Nak to userspace
Browse files Browse the repository at this point in the history
If we get a Nak we should relay that information to userspace so that it
is aware.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
  • Loading branch information
alistair23 committed Dec 21, 2023
1 parent 153df7d commit f3d76d4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions capsules/core/src/i2c_master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl<'a, I: i2c::I2CMaster<'a>> SyscallDriver for I2CMasterDriver<'a, I> {
}

impl<'a, I: i2c::I2CMaster<'a>> i2c::I2CHwMasterClient for I2CMasterDriver<'a, I> {
fn command_complete(&self, buffer: &'static mut [u8], _status: Result<(), i2c::Error>) {
fn command_complete(&self, buffer: &'static mut [u8], status: Result<(), i2c::Error>) {
self.tx.take().map(|tx| {
self.apps.enter(tx.processid, |_, kernel_data| {
if let Some(read_len) = tx.read_len.take() {
Expand All @@ -205,7 +205,18 @@ impl<'a, I: i2c::I2CMaster<'a>> i2c::I2CHwMasterClient for I2CMasterDriver<'a, I
}

// signal to driver that tx complete
kernel_data.schedule_upcall(0, (0, 0, 0)).ok();
if let Err(e) = status {
kernel_data
.schedule_upcall(
0,
(kernel::errorcode::into_statuscode(Err(e.into())), 0, 0),
)
.ok();
} else {
kernel_data
.schedule_upcall(0, (kernel::errorcode::into_statuscode(Ok(())), 0, 0))
.ok();
}
})
});

Expand Down

0 comments on commit f3d76d4

Please sign in to comment.