Skip to content

Commit c4ab63e

Browse files
credmontylerwhall
authored andcommitted
zephyr::uart::uart_err_check():: Change return to a Option<u32>
1 parent f24daad commit c4ab63e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

rust-app/zephyr/src/uart.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub trait UartSyscalls {
66

77
fn uart_poll_in(device: &Device) -> Result<Option<char>, u32>;
88

9-
fn uart_err_check(device: &Device) -> i32;
9+
fn uart_err_check(device: &Device) -> Option<u32>;
1010

1111
fn uart_config_get(device: &Device) -> Result<UartConfig, u32>;
1212

@@ -47,10 +47,16 @@ macro_rules! trait_impl {
4747
}
4848

4949
#[inline(always)]
50-
fn uart_err_check(device: &Device) -> i32 {
51-
(unsafe {
50+
fn uart_err_check(device: &Device) -> Option<u32> {
51+
let rc = unsafe {
5252
zephyr_sys::syscalls::$context::uart_err_check(device as *const _ as *mut _)
53-
})
53+
}
54+
.neg_err();
55+
56+
match rc {
57+
Ok(_) => None,
58+
Err(e) => Some(e),
59+
}
5460
}
5561

5662
#[inline(always)]

0 commit comments

Comments
 (0)