summary refs log tree commit diff
path: root/devices/src/usb/xhci/interrupter.rs
diff options
context:
space:
mode:
Diffstat (limited to 'devices/src/usb/xhci/interrupter.rs')
-rw-r--r--devices/src/usb/xhci/interrupter.rs52
1 files changed, 23 insertions, 29 deletions
diff --git a/devices/src/usb/xhci/interrupter.rs b/devices/src/usb/xhci/interrupter.rs
index e850eb2..a896fb4 100644
--- a/devices/src/usb/xhci/interrupter.rs
+++ b/devices/src/usb/xhci/interrupter.rs
@@ -83,14 +83,12 @@ impl Interrupter {
     /// Send port status change trb for port.
     pub fn send_port_status_change_trb(&mut self, port_id: u8) -> Result<()> {
         let mut trb = Trb::new();
-        {
-            let psctrb = trb
-                .cast_mut::<PortStatusChangeEventTrb>()
-                .map_err(Error::CastTrb)?;
-            psctrb.set_port_id(port_id);
-            psctrb.set_completion_code(TrbCompletionCode::Success as u8);
-            psctrb.set_trb_type(TrbType::PortStatusChangeEvent as u8);
-        }
+        let psctrb = trb
+            .cast_mut::<PortStatusChangeEventTrb>()
+            .map_err(Error::CastTrb)?;
+        psctrb.set_port_id(port_id);
+        psctrb.set_completion_code(TrbCompletionCode::Success as u8);
+        psctrb.set_trb_type(TrbType::PortStatusChangeEvent as u8);
         self.add_event(trb)
     }
 
@@ -102,17 +100,15 @@ impl Interrupter {
         trb_addr: GuestAddress,
     ) -> Result<()> {
         let mut trb = Trb::new();
-        {
-            let ctrb = trb
-                .cast_mut::<CommandCompletionEventTrb>()
-                .map_err(Error::CastTrb)?;
-            ctrb.set_trb_pointer(trb_addr.0);
-            ctrb.set_command_completion_parameter(0);
-            ctrb.set_completion_code(completion_code as u8);
-            ctrb.set_trb_type(TrbType::CommandCompletionEvent as u8);
-            ctrb.set_vf_id(0);
-            ctrb.set_slot_id(slot_id);
-        }
+        let ctrb = trb
+            .cast_mut::<CommandCompletionEventTrb>()
+            .map_err(Error::CastTrb)?;
+        ctrb.set_trb_pointer(trb_addr.0);
+        ctrb.set_command_completion_parameter(0);
+        ctrb.set_completion_code(completion_code as u8);
+        ctrb.set_trb_type(TrbType::CommandCompletionEvent as u8);
+        ctrb.set_vf_id(0);
+        ctrb.set_slot_id(slot_id);
         self.add_event(trb)
     }
 
@@ -127,16 +123,14 @@ impl Interrupter {
         endpoint_id: u8,
     ) -> Result<()> {
         let mut trb = Trb::new();
-        {
-            let event_trb = trb.cast_mut::<TransferEventTrb>().map_err(Error::CastTrb)?;
-            event_trb.set_trb_pointer(trb_pointer);
-            event_trb.set_trb_transfer_length(transfer_length);
-            event_trb.set_completion_code(completion_code as u8);
-            event_trb.set_event_data(event_data.into());
-            event_trb.set_trb_type(TrbType::TransferEvent as u8);
-            event_trb.set_endpoint_id(endpoint_id);
-            event_trb.set_slot_id(slot_id);
-        }
+        let event_trb = trb.cast_mut::<TransferEventTrb>().map_err(Error::CastTrb)?;
+        event_trb.set_trb_pointer(trb_pointer);
+        event_trb.set_trb_transfer_length(transfer_length);
+        event_trb.set_completion_code(completion_code as u8);
+        event_trb.set_event_data(event_data.into());
+        event_trb.set_trb_type(TrbType::TransferEvent as u8);
+        event_trb.set_endpoint_id(endpoint_id);
+        event_trb.set_slot_id(slot_id);
         self.add_event(trb)
     }