Skip to content

Commit 780f63c

Browse files
committed
zpehyr: Code formatting updates
Run `cargo fmt` in zephyr. Signed-off-by: David Brown <[email protected]>
1 parent e16cfe7 commit 780f63c

File tree

5 files changed

+26
-30
lines changed

5 files changed

+26
-30
lines changed

zephyr/src/device/gpio.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ mod async_io {
3535
ZR_GPIO_INT_MODE_DISABLE_ONLY,
3636
};
3737

38-
use crate::{printkln, sync::atomic::{AtomicBool, AtomicU32}};
38+
use crate::{
39+
printkln,
40+
sync::atomic::{AtomicBool, AtomicU32},
41+
};
3942

4043
use super::{GpioPin, GpioToken};
4144

zephyr/src/device/i2c.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,7 @@ impl I2C {
4343
flags: raw::ZR_I2C_MSG_READ | raw::ZR_I2C_MSG_STOP,
4444
},
4545
];
46-
let res = unsafe {
47-
to_result(
48-
raw::i2c_transfer(
49-
self.device,
50-
msg.as_mut_ptr(),
51-
2,
52-
0x42,
53-
))
54-
};
46+
let res = unsafe { to_result(raw::i2c_transfer(self.device, msg.as_mut_ptr(), 2, 0x42)) };
5547

5648
printkln!("res: {} {}", msg[1].len, msg[1].flags);
5749

zephyr/src/embassy/executor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
33
use core::marker::PhantomData;
44

5-
use embassy_executor::{raw, Spawner};
65
use crate::sys::sync::Semaphore;
76
use crate::time::Forever;
7+
use embassy_executor::{raw, Spawner};
88

99
/// Zephyr-thread based executor.
1010
pub struct Executor {

zephyr/src/rtio.rs

+18-17
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use core::ffi::c_void;
44

55
use crate::error::to_result_void;
6-
use crate::raw;
76
use crate::object::{ObjectInit, ZephyrObject};
7+
use crate::raw;
88

99
/// The underlying structure, holding the rtio, it's semaphores, and pools.
1010
///
@@ -27,15 +27,17 @@ pub struct RtioData<const SQE_SZ: usize, const CQE_SZ: usize> {
2727
/// The CQE items.
2828
cqe_pool_items: [raw::rtio_cqe; CQE_SZ],
2929
/// The pool of CQEs.
30-
cqe_pool: raw:: rtio_cqe_pool,
30+
cqe_pool: raw::rtio_cqe_pool,
3131
}
3232

3333
/// Init based reference to the the underlying rtio object.
3434
///
3535
/// Note that this declaration will _not_ support userspace currently, as the object will not be
3636
/// placed in an iterable linker section. Also, the linker sevction will not work as the
3737
/// ZephyrObject will have an attached atomic used to ensure proper initialization.
38-
pub struct RtioObject<const SQE_SZ: usize, const CQE_SZ: usize>(pub(crate) ZephyrObject<RtioData<SQE_SZ, CQE_SZ>>);
38+
pub struct RtioObject<const SQE_SZ: usize, const CQE_SZ: usize>(
39+
pub(crate) ZephyrObject<RtioData<SQE_SZ, CQE_SZ>>,
40+
);
3941

4042
unsafe impl<const SQE_SZ: usize, const CQE_SZ: usize> Sync for RtioObject<SQE_SZ, CQE_SZ> {}
4143

@@ -52,9 +54,7 @@ impl<const SQE_SZ: usize, const CQE_SZ: usize> RtioObject<SQE_SZ, CQE_SZ> {
5254
pub fn sqe_acquire(&'static self) -> Option<Sqe> {
5355
let this = unsafe { self.0.get() };
5456

55-
let ptr = unsafe {
56-
raw::rtio_sqe_acquire(&raw mut (*this).rtio)
57-
};
57+
let ptr = unsafe { raw::rtio_sqe_acquire(&raw mut (*this).rtio) };
5858

5959
if ptr.is_null() {
6060
None
@@ -67,9 +67,7 @@ impl<const SQE_SZ: usize, const CQE_SZ: usize> RtioObject<SQE_SZ, CQE_SZ> {
6767
pub fn submit(&'static self, wait: usize) -> crate::Result<()> {
6868
let this = unsafe { self.0.get() };
6969

70-
unsafe {
71-
to_result_void(raw::rtio_submit(&raw mut (*this).rtio, wait as u32))
72-
}
70+
unsafe { to_result_void(raw::rtio_submit(&raw mut (*this).rtio, wait as u32)) }
7371
}
7472

7573
/// Consume a single completion.
@@ -78,9 +76,7 @@ impl<const SQE_SZ: usize, const CQE_SZ: usize> RtioObject<SQE_SZ, CQE_SZ> {
7876
pub fn cqe_consume(&'static self) -> Option<Cqe> {
7977
let this = unsafe { self.0.get() };
8078

81-
let ptr = unsafe {
82-
raw::rtio_cqe_consume(&raw mut (*this).rtio)
83-
};
79+
let ptr = unsafe { raw::rtio_cqe_consume(&raw mut (*this).rtio) };
8480

8581
if ptr.is_null() {
8682
None
@@ -93,7 +89,9 @@ impl<const SQE_SZ: usize, const CQE_SZ: usize> RtioObject<SQE_SZ, CQE_SZ> {
9389
}
9490
}
9591

96-
impl<const SQE_SZ: usize, const CQE_SZ: usize> ObjectInit<RtioData<SQE_SZ, CQE_SZ>> for ZephyrObject<RtioData<SQE_SZ, CQE_SZ>> {
92+
impl<const SQE_SZ: usize, const CQE_SZ: usize> ObjectInit<RtioData<SQE_SZ, CQE_SZ>>
93+
for ZephyrObject<RtioData<SQE_SZ, CQE_SZ>>
94+
{
9795
fn init(item: *mut RtioData<SQE_SZ, CQE_SZ>) {
9896
#[cfg(CONFIG_RTIO_SUBMIT_SEM)]
9997
unsafe {
@@ -149,7 +147,12 @@ pub struct Sqe {
149147

150148
impl Sqe {
151149
/// Configure this SQE as a callback.
152-
pub fn prep_callback(&mut self, callback: raw::rtio_callback_t, arg0: *mut c_void, userdata: *mut c_void) {
150+
pub fn prep_callback(
151+
&mut self,
152+
callback: raw::rtio_callback_t,
153+
arg0: *mut c_void,
154+
userdata: *mut c_void,
155+
) {
153156
unsafe {
154157
raw::rtio_sqe_prep_callback(self.item, callback, arg0, userdata);
155158
}
@@ -179,9 +182,7 @@ pub struct Cqe {
179182
impl Cqe {
180183
/// Retrieve the result of this operation.
181184
pub fn result(&self) -> i32 {
182-
unsafe {
183-
(*self.item).result
184-
}
185+
unsafe { (*self.item).result }
185186
}
186187
}
187188

zephyr/src/work.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,8 @@ impl<T: SimpleAction + Send> Work<T> {
554554

555555
// SAFETY: The Pin ensures this will not move. Our implementation of drop ensures that the
556556
// work item is no longer queued when the data is dropped.
557-
let result = SubmitResult::to_result(unsafe { k_work_submit_to_queue(queue.item.get(), work) });
557+
let result =
558+
SubmitResult::to_result(unsafe { k_work_submit_to_queue(queue.item.get(), work) });
558559

559560
Self::check_drop(work, &result);
560561

@@ -609,7 +610,6 @@ impl<T: SimpleAction + Send> Work<T> {
609610
drop(this);
610611
}
611612
}
612-
613613
}
614614

615615
/// Access the inner action.

0 commit comments

Comments
 (0)