garage44.eu/jeroen/pinnacle

logclone: git clone https://garage44.eu/jeroen/pinnacle.git

cartopolis-agent · 2026-11-30T15:18:05Z

style(kernel): rustfmt the OHCI driver
kernel/src/drivers/usb/ohci.rs | 57 +++++++++++++++++++++++++++++++++++-------
 1 file changed, 48 insertions(+), 9 deletions(-)

diff --git a/kernel/src/drivers/usb/ohci.rs b/kernel/src/drivers/usb/ohci.rs
index 5d6f20a..08c1b7d 100644
--- a/kernel/src/drivers/usb/ohci.rs
+++ b/kernel/src/drivers/usb/ohci.rs
@@ -267,7 +267,10 @@ impl Ohci {
             address: 0,
         };
         if c.read(REVISION) & 0xff != 0x10 {
-            println!("ohci{number}: revision {:#x}, not OHCI 1.0", c.read(REVISION) & 0xff);
+            println!(
+                "ohci{number}: revision {:#x}, not OHCI 1.0",
+                c.read(REVISION) & 0xff
+            );
             return None;
         }
         c.control_ed = c.cell()?;
@@ -305,7 +308,10 @@ impl Ohci {
         // periodic transfers from 90 % of it (OHCI 1.0a, 5.1.1.4).
         let interval = 11_999;
         let toggle = !c.read(FRAME_INTERVAL) & 1 << 31;
-        c.write(FRAME_INTERVAL, toggle | ((interval - 210) * 6 / 7) << 16 | interval);
+        c.write(
+            FRAME_INTERVAL,
+            toggle | ((interval - 210) * 6 / 7) << 16 | interval,
+        );
         c.write(PERIODIC_START, interval * 9 / 10);
         c.write(LOW_SPEED_THRESHOLD, 0x628);
         c.write(INTERRUPT_STATUS, 0x7f);
@@ -325,7 +331,15 @@ impl Ohci {
     /// time): the setup packet `request`, its data (`length` bytes in or
     /// out of `buffer`, a page of ours). Waited for by polling: it runs at
     /// boot. The bytes moved, or None when it failed.
-    fn control(&self, address: u8, packet: u16, low: bool, request: [u8; 8], buffer: usize, length: usize) -> Option<usize> {
+    fn control(
+        &self,
+        address: u8,
+        packet: u16,
+        low: bool,
+        request: [u8; 8],
+        buffer: usize,
+        length: usize,
+    ) -> Option<usize> {
         let into_host = request[0] & 0x80 != 0;
         let [setup, data, status, tail] = self.control_tds;
         // SAFETY: the setup cell, ours.
@@ -335,7 +349,12 @@ impl Ohci {
         let after_setup = if length > 0 { data } else { status };
         set(
             setup,
-            [TD_NOT_ACCESSED | TD_SETUP | TD_DATA0 | TD_QUIET, bus(self.setup), bus(after_setup), bus(self.setup) + 7],
+            [
+                TD_NOT_ACCESSED | TD_SETUP | TD_DATA0 | TD_QUIET,
+                bus(self.setup),
+                bus(after_setup),
+                bus(self.setup) + 7,
+            ],
         );
         if length > 0 {
             let direction = if into_host { TD_IN | TD_ROUNDING } else { TD_OUT };
@@ -351,7 +370,10 @@ impl Ohci {
         }
         // The status stage goes the other way, or in when there is no data.
         let back = if length == 0 || !into_host { TD_IN } else { TD_OUT };
-        set(status, [TD_NOT_ACCESSED | back | TD_DATA1 | TD_QUIET, 0, bus(tail), 0]);
+        set(
+            status,
+            [TD_NOT_ACCESSED | back | TD_DATA1 | TD_QUIET, 0, bus(tail), 0],
+        );
         // The endpoint, skipped meanwhile (it is empty: nothing in flight).
         let speed = if low { ED_LOW_SPEED } else { 0 };
         let first = u32::from(address) | speed | u32::from(packet) << 16;
@@ -383,16 +405,30 @@ impl Ohci {
         sync(buffer, length);
         // Its current buffer pointer: 0 when every byte moved, else the next.
         let at = word(data, 1);
-        Some(if at == 0 { length } else { (at - bus(buffer)) as usize })
+        Some(if at == 0 {
+            length
+        } else {
+            (at - bus(buffer)) as usize
+        })
     }
 
     /// Starts reading `reader`'s reports from endpoint `endpoint` of the
     /// device at `address`.
-    fn read_input(&mut self, address: u8, low: bool, endpoint: (u8, u8, u16, u8), reader: Reader) -> Option<()> {
+    fn read_input(
+        &mut self,
+        address: u8,
+        low: bool,
+        endpoint: (u8, u8, u16, u8),
+        reader: Reader,
+    ) -> Option<()> {
         let ed = self.cell()?;
         let tds = [self.cell()?, self.cell()?];
         let speed = if low { ED_LOW_SPEED } else { 0 };
-        let first = u32::from(address) | u32::from(endpoint.0 & 0xf) << 7 | ED_IN | speed | u32::from(endpoint.2) << 16;
+        let first = u32::from(address)
+            | u32::from(endpoint.0 & 0xf) << 7
+            | ED_IN
+            | speed
+            | u32::from(endpoint.2) << 16;
         // Linked before the newest, then the frame table pointed at it: the
         // controller's own words of a live endpoint are never written over.
         let next = self.first_interrupt.map_or(0, bus);
@@ -513,7 +549,10 @@ impl Ohci {
             taken += 1;
         }
         if taken == 0 {
-            println!("ohci{}: port {port}: {}, no driver for it", self.number, d.product_name);
+            println!(
+                "ohci{}: port {port}: {}, no driver for it",
+                self.number, d.product_name
+            );
         }
         taken
     }