@@ -186,18 +186,13 @@ impl<B: UsbBus> ControlPipe<'_, B> {
186
186
Ok ( None )
187
187
}
188
188
189
- pub fn handle_in_complete ( & mut self ) -> bool {
189
+ pub fn handle_in_complete ( & mut self ) -> Result < bool > {
190
190
match self . state {
191
191
ControlState :: DataIn => {
192
- self . write_in_chunk ( ) ;
192
+ self . write_in_chunk ( ) ? ;
193
193
}
194
194
ControlState :: DataInZlp => {
195
- if self . ep_in . write ( & [ ] ) . is_err ( ) {
196
- // There isn't much we can do if the write fails, except to wait for another
197
- // poll or for the host to resend the request.
198
- return false ;
199
- }
200
-
195
+ self . ep_in . write ( & [ ] ) ?;
201
196
usb_trace ! ( "wrote EP0: ZLP" ) ;
202
197
self . state = ControlState :: DataInLast ;
203
198
}
@@ -207,7 +202,7 @@ impl<B: UsbBus> ControlPipe<'_, B> {
207
202
}
208
203
ControlState :: StatusIn => {
209
204
self . state = ControlState :: Idle ;
210
- return true ;
205
+ return Ok ( true ) ;
211
206
}
212
207
ControlState :: Idle => {
213
208
// If we received a message on EP0 while sending the last portion of an IN
@@ -221,23 +216,14 @@ impl<B: UsbBus> ControlPipe<'_, B> {
221
216
}
222
217
} ;
223
218
224
- false
219
+ Ok ( false )
225
220
}
226
221
227
- fn write_in_chunk ( & mut self ) {
222
+ fn write_in_chunk ( & mut self ) -> Result < ( ) > {
228
223
let count = min ( self . len - self . i , self . ep_in . max_packet_size ( ) as usize ) ;
229
224
230
225
let buffer = self . static_in_buf . unwrap_or ( & self . buf ) ;
231
- let count = match self . ep_in . write ( & buffer[ self . i ..( self . i + count) ] ) {
232
- Ok ( c) => c,
233
- // There isn't much we can do if the write fails, except to wait for another poll or for
234
- // the host to resend the request.
235
- Err ( _err) => {
236
- usb_debug ! ( "Failed to write EP0: {:?}" , _err) ;
237
- return ;
238
- }
239
- } ;
240
-
226
+ let count = self . ep_in . write ( & buffer[ self . i ..( self . i + count) ] ) ?;
241
227
usb_trace ! ( "wrote EP0: {:?}" , & buffer[ self . i..( self . i + count) ] ) ;
242
228
243
229
self . i += count;
@@ -251,6 +237,8 @@ impl<B: UsbBus> ControlPipe<'_, B> {
251
237
ControlState :: DataInLast
252
238
} ;
253
239
}
240
+
241
+ Ok ( ( ) )
254
242
}
255
243
256
244
pub fn accept_out ( & mut self ) -> Result < ( ) > {
@@ -304,7 +292,7 @@ impl<B: UsbBus> ControlPipe<'_, B> {
304
292
self . len = min ( data_len, req. length as usize ) ;
305
293
self . i = 0 ;
306
294
self . state = ControlState :: DataIn ;
307
- self . write_in_chunk ( ) ;
295
+ self . write_in_chunk ( ) ? ;
308
296
309
297
Ok ( ( ) )
310
298
}
0 commit comments