@@ -20,6 +20,19 @@ enum bmm350_stream_state {
20
20
BMM350_STREAM_BUSY = 2 ,
21
21
};
22
22
23
+ static void bmm350_stream_result (const struct device * dev , int err )
24
+ {
25
+ struct bmm350_data * data = dev -> data ;
26
+ struct rtio_iodev_sqe * iodev_sqe = data -> stream .iodev_sqe ;
27
+
28
+ data -> stream .iodev_sqe = NULL ;
29
+ if (err < 0 ) {
30
+ rtio_iodev_sqe_err (iodev_sqe , err );
31
+ } else {
32
+ rtio_iodev_sqe_ok (iodev_sqe , 0 );
33
+ }
34
+ }
35
+
23
36
static void bmm350_stream_event_complete (struct rtio * ctx , const struct rtio_sqe * sqe , void * arg0 )
24
37
{
25
38
struct rtio_iodev_sqe * iodev_sqe = (struct rtio_iodev_sqe * )arg0 ;
@@ -69,13 +82,7 @@ static void bmm350_stream_event_complete(struct rtio *ctx, const struct rtio_sqe
69
82
70
83
bmm350_stream_evt_finish :
71
84
atomic_set (& data -> stream .state , BMM350_STREAM_ON );
72
-
73
- if (err < 0 ) {
74
- rtio_iodev_sqe_err (iodev_sqe , err );
75
- } else {
76
- rtio_iodev_sqe_ok (iodev_sqe , 0 );
77
- }
78
-
85
+ bmm350_stream_result (dev , err );
79
86
}
80
87
81
88
static void bmm350_event_handler (const struct device * dev )
@@ -115,7 +122,7 @@ static void bmm350_event_handler(const struct device *dev)
115
122
& buf , & buf_len );
116
123
CHECKIF (err != 0 || buf_len < sizeof (struct bmm350_encoded_data )) {
117
124
LOG_ERR ("Failed to allocate BMM350 encoded buffer: %d" , err );
118
- rtio_iodev_sqe_err ( iodev_sqe , - ENOMEM );
125
+ bmm350_stream_result ( dev , - ENOMEM );
119
126
return ;
120
127
}
121
128
@@ -127,7 +134,7 @@ static void bmm350_event_handler(const struct device *dev)
127
134
edata -> payload .buf , sizeof (edata -> payload .buf ),
128
135
& read_sqe );
129
136
CHECKIF (err < 0 || !read_sqe ) {
130
- rtio_iodev_sqe_err ( iodev_sqe , err );
137
+ bmm350_stream_result ( dev , err );
131
138
return ;
132
139
}
133
140
read_sqe -> flags |= RTIO_SQE_CHAINED ;
@@ -169,14 +176,14 @@ void bmm350_stream_submit(const struct device *dev,
169
176
/* Set PMU command configuration */
170
177
err = bmm350_prep_reg_write_async (dev , BMM350_REG_INT_CTRL , cfg -> int_flags , NULL );
171
178
if (err < 0 ) {
172
- rtio_iodev_sqe_err ( iodev_sqe , err );
179
+ bmm350_stream_result ( dev , err );
173
180
return ;
174
181
}
175
182
rtio_submit (cfg -> bus .rtio .ctx , 0 );
176
183
177
184
err = gpio_pin_interrupt_configure_dt (& cfg -> drdy_int , GPIO_INT_EDGE_TO_ACTIVE );
178
185
if (err < 0 ) {
179
- rtio_iodev_sqe_err ( iodev_sqe , err );
186
+ bmm350_stream_result ( dev , err );
180
187
return ;
181
188
}
182
189
}
0 commit comments