3
3
use core:: ffi:: c_void;
4
4
5
5
use crate :: error:: to_result_void;
6
- use crate :: raw;
7
6
use crate :: object:: { ObjectInit , ZephyrObject } ;
7
+ use crate :: raw;
8
8
9
9
/// The underlying structure, holding the rtio, it's semaphores, and pools.
10
10
///
@@ -27,15 +27,17 @@ pub struct RtioData<const SQE_SZ: usize, const CQE_SZ: usize> {
27
27
/// The CQE items.
28
28
cqe_pool_items : [ raw:: rtio_cqe ; CQE_SZ ] ,
29
29
/// The pool of CQEs.
30
- cqe_pool : raw:: rtio_cqe_pool ,
30
+ cqe_pool : raw:: rtio_cqe_pool ,
31
31
}
32
32
33
33
/// Init based reference to the the underlying rtio object.
34
34
///
35
35
/// Note that this declaration will _not_ support userspace currently, as the object will not be
36
36
/// placed in an iterable linker section. Also, the linker sevction will not work as the
37
37
/// 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
+ ) ;
39
41
40
42
unsafe impl < const SQE_SZ : usize , const CQE_SZ : usize > Sync for RtioObject < SQE_SZ , CQE_SZ > { }
41
43
@@ -52,9 +54,7 @@ impl<const SQE_SZ: usize, const CQE_SZ: usize> RtioObject<SQE_SZ, CQE_SZ> {
52
54
pub fn sqe_acquire ( & ' static self ) -> Option < Sqe > {
53
55
let this = unsafe { self . 0 . get ( ) } ;
54
56
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 ) } ;
58
58
59
59
if ptr. is_null ( ) {
60
60
None
@@ -67,9 +67,7 @@ impl<const SQE_SZ: usize, const CQE_SZ: usize> RtioObject<SQE_SZ, CQE_SZ> {
67
67
pub fn submit ( & ' static self , wait : usize ) -> crate :: Result < ( ) > {
68
68
let this = unsafe { self . 0 . get ( ) } ;
69
69
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 ) ) }
73
71
}
74
72
75
73
/// Consume a single completion.
@@ -78,9 +76,7 @@ impl<const SQE_SZ: usize, const CQE_SZ: usize> RtioObject<SQE_SZ, CQE_SZ> {
78
76
pub fn cqe_consume ( & ' static self ) -> Option < Cqe > {
79
77
let this = unsafe { self . 0 . get ( ) } ;
80
78
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 ) } ;
84
80
85
81
if ptr. is_null ( ) {
86
82
None
@@ -93,7 +89,9 @@ impl<const SQE_SZ: usize, const CQE_SZ: usize> RtioObject<SQE_SZ, CQE_SZ> {
93
89
}
94
90
}
95
91
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
+ {
97
95
fn init ( item : * mut RtioData < SQE_SZ , CQE_SZ > ) {
98
96
#[ cfg( CONFIG_RTIO_SUBMIT_SEM ) ]
99
97
unsafe {
@@ -149,7 +147,12 @@ pub struct Sqe {
149
147
150
148
impl Sqe {
151
149
/// 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
+ ) {
153
156
unsafe {
154
157
raw:: rtio_sqe_prep_callback ( self . item , callback, arg0, userdata) ;
155
158
}
@@ -179,9 +182,7 @@ pub struct Cqe {
179
182
impl Cqe {
180
183
/// Retrieve the result of this operation.
181
184
pub fn result ( & self ) -> i32 {
182
- unsafe {
183
- ( * self . item ) . result
184
- }
185
+ unsafe { ( * self . item ) . result }
185
186
}
186
187
}
187
188
0 commit comments