@@ -182,6 +182,7 @@ impl<B: UsbBus> UsbDevice<'_, B> {
182
182
}
183
183
_ => {
184
184
self . bus . resume ( ) ;
185
+
185
186
self . device_state = self
186
187
. suspended_device_state
187
188
. expect ( "Unknown state before suspend" ) ;
@@ -213,14 +214,24 @@ impl<B: UsbBus> UsbDevice<'_, B> {
213
214
let req = if ( ep_setup & 1 ) != 0 {
214
215
self . control . handle_setup ( )
215
216
} else if ( ep_out & 1 ) != 0 {
216
- self . control . handle_out ( )
217
+ match self . control . handle_out ( ) {
218
+ Ok ( req) => req,
219
+ Err ( _err) => {
220
+ // TODO: Propagate error out of `poll()`
221
+ usb_debug ! ( "Failed to handle EP0: {_err}" ) ;
222
+ None
223
+ }
224
+ }
217
225
} else {
218
226
None
219
227
} ;
220
228
221
229
match req {
222
230
Some ( req) if req. direction == UsbDirection :: In => {
223
- self . control_in ( classes, req)
231
+ if let Err ( _err) = self . control_in ( classes, req) {
232
+ // TODO: Propagate error out of `poll()`
233
+ usb_debug ! ( "Failed to handle control request: {_err}" ) ;
234
+ }
224
235
}
225
236
Some ( req) if req. direction == UsbDirection :: Out => {
226
237
self . control_out ( classes, req)
@@ -310,14 +321,14 @@ impl<B: UsbBus> UsbDevice<'_, B> {
310
321
false
311
322
}
312
323
313
- fn control_in ( & mut self , classes : & mut ClassList < ' _ , B > , req : control:: Request ) {
324
+ fn control_in ( & mut self , classes : & mut ClassList < ' _ , B > , req : control:: Request ) -> Result < ( ) > {
314
325
use crate :: control:: { Recipient , Request } ;
315
326
316
327
for cls in classes. iter_mut ( ) {
317
328
cls. control_in ( ControlIn :: new ( & mut self . control , & req) ) ;
318
329
319
330
if !self . control . waiting_for_response ( ) {
320
- return ;
331
+ return Ok ( ( ) ) ;
321
332
}
322
333
}
323
334
@@ -334,14 +345,14 @@ impl<B: UsbBus> UsbDevice<'_, B> {
334
345
0x0000
335
346
} ;
336
347
337
- let _ = xfer. accept_with ( & status. to_le_bytes ( ) ) ;
348
+ xfer. accept_with ( & status. to_le_bytes ( ) ) ? ;
338
349
}
339
350
340
351
( Recipient :: Interface , Request :: GET_STATUS ) => {
341
352
usb_trace ! ( "Processing Interface::GetStatus" ) ;
342
353
let status: u16 = 0x0000 ;
343
354
344
- let _ = xfer. accept_with ( & status. to_le_bytes ( ) ) ;
355
+ xfer. accept_with ( & status. to_le_bytes ( ) ) ? ;
345
356
}
346
357
347
358
( Recipient :: Endpoint , Request :: GET_STATUS ) => {
@@ -354,7 +365,7 @@ impl<B: UsbBus> UsbDevice<'_, B> {
354
365
0x0000
355
366
} ;
356
367
357
- let _ = xfer. accept_with ( & status. to_le_bytes ( ) ) ;
368
+ xfer. accept_with ( & status. to_le_bytes ( ) ) ? ;
358
369
}
359
370
360
371
( Recipient :: Device , Request :: GET_DESCRIPTOR ) => {
@@ -369,39 +380,39 @@ impl<B: UsbBus> UsbDevice<'_, B> {
369
380
_ => CONFIGURATION_NONE ,
370
381
} ;
371
382
372
- let _ = xfer. accept_with ( & config. to_le_bytes ( ) ) ;
383
+ xfer. accept_with ( & config. to_le_bytes ( ) ) ? ;
373
384
}
374
385
375
386
( Recipient :: Interface , Request :: GET_INTERFACE ) => {
376
387
usb_trace ! ( "Processing Interface::GetInterface" ) ;
377
388
// Reject interface numbers bigger than 255
378
389
if req. index > core:: u8:: MAX . into ( ) {
379
- let _ = xfer. reject ( ) ;
380
- return ;
390
+ return xfer. reject ( ) ;
381
391
}
382
392
383
393
// Ask class implementations, whether they know the alternate setting
384
394
// of the interface in question
385
395
for cls in classes {
386
396
if let Some ( setting) = cls. get_alt_setting ( InterfaceNumber ( req. index as u8 ) )
387
397
{
388
- let _ = xfer. accept_with ( & setting. to_le_bytes ( ) ) ;
389
- return ;
398
+ return xfer. accept_with ( & setting. to_le_bytes ( ) ) ;
390
399
}
391
400
}
392
401
393
402
// If no class returned an alternate setting, return the default value
394
- let _ = xfer. accept_with ( & DEFAULT_ALTERNATE_SETTING . to_le_bytes ( ) ) ;
403
+ xfer. accept_with ( & DEFAULT_ALTERNATE_SETTING . to_le_bytes ( ) ) ? ;
395
404
}
396
405
397
- _ => ( ) ,
406
+ _ => { }
398
407
} ;
399
408
}
400
409
401
410
if self . control . waiting_for_response ( ) {
402
411
usb_debug ! ( "Rejecting control transfer because we were waiting for a response" ) ;
403
- let _ = self . control . reject ( ) ;
412
+ self . control . reject ( ) ? ;
404
413
}
414
+
415
+ Ok ( ( ) )
405
416
}
406
417
407
418
fn control_out ( & mut self , classes : & mut ClassList < ' _ , B > , req : control:: Request ) {
0 commit comments