@@ -186,18 +186,13 @@ impl<B: UsbBus> ControlPipe<'_, B> {
186186 Ok ( None )
187187 }
188188
189- pub fn handle_in_complete ( & mut self ) -> bool {
189+ pub fn handle_in_complete ( & mut self ) -> Result < bool > {
190190 match self . state {
191191 ControlState :: DataIn => {
192- self . write_in_chunk ( ) ;
192+ self . write_in_chunk ( ) ? ;
193193 }
194194 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 ( & [ ] ) ?;
201196 usb_trace ! ( "wrote EP0: ZLP" ) ;
202197 self . state = ControlState :: DataInLast ;
203198 }
@@ -207,7 +202,7 @@ impl<B: UsbBus> ControlPipe<'_, B> {
207202 }
208203 ControlState :: StatusIn => {
209204 self . state = ControlState :: Idle ;
210- return true ;
205+ return Ok ( true ) ;
211206 }
212207 ControlState :: Idle => {
213208 // If we received a message on EP0 while sending the last portion of an IN
@@ -221,23 +216,14 @@ impl<B: UsbBus> ControlPipe<'_, B> {
221216 }
222217 } ;
223218
224- false
219+ Ok ( false )
225220 }
226221
227- fn write_in_chunk ( & mut self ) {
222+ fn write_in_chunk ( & mut self ) -> Result < ( ) > {
228223 let count = min ( self . len - self . i , self . ep_in . max_packet_size ( ) as usize ) ;
229224
230225 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) ] ) ?;
241227 usb_trace ! ( "wrote EP0: {:?}" , & buffer[ self . i..( self . i + count) ] ) ;
242228
243229 self . i += count;
@@ -251,6 +237,8 @@ impl<B: UsbBus> ControlPipe<'_, B> {
251237 ControlState :: DataInLast
252238 } ;
253239 }
240+
241+ Ok ( ( ) )
254242 }
255243
256244 pub fn accept_out ( & mut self ) -> Result < ( ) > {
@@ -304,7 +292,7 @@ impl<B: UsbBus> ControlPipe<'_, B> {
304292 self . len = min ( data_len, req. length as usize ) ;
305293 self . i = 0 ;
306294 self . state = ControlState :: DataIn ;
307- self . write_in_chunk ( ) ;
295+ self . write_in_chunk ( ) ? ;
308296
309297 Ok ( ( ) )
310298 }
0 commit comments