@@ -182,6 +182,7 @@ impl<B: UsbBus> UsbDevice<'_, B> {
182182 }
183183 _ => {
184184 self . bus . resume ( ) ;
185+
185186 self . device_state = self
186187 . suspended_device_state
187188 . expect ( "Unknown state before suspend" ) ;
@@ -213,14 +214,24 @@ impl<B: UsbBus> UsbDevice<'_, B> {
213214 let req = if ( ep_setup & 1 ) != 0 {
214215 self . control . handle_setup ( )
215216 } 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+ }
217225 } else {
218226 None
219227 } ;
220228
221229 match req {
222230 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+ }
224235 }
225236 Some ( req) if req. direction == UsbDirection :: Out => {
226237 self . control_out ( classes, req)
@@ -310,14 +321,14 @@ impl<B: UsbBus> UsbDevice<'_, B> {
310321 false
311322 }
312323
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 < ( ) > {
314325 use crate :: control:: { Recipient , Request } ;
315326
316327 for cls in classes. iter_mut ( ) {
317328 cls. control_in ( ControlIn :: new ( & mut self . control , & req) ) ;
318329
319330 if !self . control . waiting_for_response ( ) {
320- return ;
331+ return Ok ( ( ) ) ;
321332 }
322333 }
323334
@@ -334,14 +345,14 @@ impl<B: UsbBus> UsbDevice<'_, B> {
334345 0x0000
335346 } ;
336347
337- let _ = xfer. accept_with ( & status. to_le_bytes ( ) ) ;
348+ xfer. accept_with ( & status. to_le_bytes ( ) ) ? ;
338349 }
339350
340351 ( Recipient :: Interface , Request :: GET_STATUS ) => {
341352 usb_trace ! ( "Processing Interface::GetStatus" ) ;
342353 let status: u16 = 0x0000 ;
343354
344- let _ = xfer. accept_with ( & status. to_le_bytes ( ) ) ;
355+ xfer. accept_with ( & status. to_le_bytes ( ) ) ? ;
345356 }
346357
347358 ( Recipient :: Endpoint , Request :: GET_STATUS ) => {
@@ -354,7 +365,7 @@ impl<B: UsbBus> UsbDevice<'_, B> {
354365 0x0000
355366 } ;
356367
357- let _ = xfer. accept_with ( & status. to_le_bytes ( ) ) ;
368+ xfer. accept_with ( & status. to_le_bytes ( ) ) ? ;
358369 }
359370
360371 ( Recipient :: Device , Request :: GET_DESCRIPTOR ) => {
@@ -369,39 +380,39 @@ impl<B: UsbBus> UsbDevice<'_, B> {
369380 _ => CONFIGURATION_NONE ,
370381 } ;
371382
372- let _ = xfer. accept_with ( & config. to_le_bytes ( ) ) ;
383+ xfer. accept_with ( & config. to_le_bytes ( ) ) ? ;
373384 }
374385
375386 ( Recipient :: Interface , Request :: GET_INTERFACE ) => {
376387 usb_trace ! ( "Processing Interface::GetInterface" ) ;
377388 // Reject interface numbers bigger than 255
378389 if req. index > core:: u8:: MAX . into ( ) {
379- let _ = xfer. reject ( ) ;
380- return ;
390+ return xfer. reject ( ) ;
381391 }
382392
383393 // Ask class implementations, whether they know the alternate setting
384394 // of the interface in question
385395 for cls in classes {
386396 if let Some ( setting) = cls. get_alt_setting ( InterfaceNumber ( req. index as u8 ) )
387397 {
388- let _ = xfer. accept_with ( & setting. to_le_bytes ( ) ) ;
389- return ;
398+ return xfer. accept_with ( & setting. to_le_bytes ( ) ) ;
390399 }
391400 }
392401
393402 // 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 ( ) ) ? ;
395404 }
396405
397- _ => ( ) ,
406+ _ => { }
398407 } ;
399408 }
400409
401410 if self . control . waiting_for_response ( ) {
402411 usb_debug ! ( "Rejecting control transfer because we were waiting for a response" ) ;
403- let _ = self . control . reject ( ) ;
412+ self . control . reject ( ) ? ;
404413 }
414+
415+ Ok ( ( ) )
405416 }
406417
407418 fn control_out ( & mut self , classes : & mut ClassList < ' _ , B > , req : control:: Request ) {
0 commit comments