Files
RedBear-OS/drivers/usb
Red Bear OS 71971d12e0 USB: P1-C xhcid hot-path panic reduction — eliminate all 27 hot-path unwrap/expect
irq_reactor.rs (8 hot):
- Mutex locks: 4x .lock().unwrap() → .lock().unwrap_or_else(|e| e.into_inner())
  (established pattern already at line 140)
- irq_file Option: 3x .as_ref()/.as_mut().unwrap() → .unwrap_or_else(|| unreachable!(...))
  (guaranteed Some by caller run())
- Event queue subscribe: .unwrap() → .expect(...)
- Event queue next_event: .unwrap() → .expect(...)

scheme.rs (11 hot):
- SSP/SS companion descriptors: 2x .as_ref().unwrap() → .map_or(0, ...)
- dev_desc.as_ref().unwrap(): 3x → .ok_or(Error::new(EBADFD))?
  (in configure_endpoints_once, endpoint config loop, get_endp_status,
   restart_endpoint, endp_direction)
- dma_buffer.as_ref().unwrap() in transfer_read → .ok_or_else(|| EIO)?
- Peekable iterator next(): 2x .unwrap() → .expect("...")

mod.rs (8 hot):
- get_pls: .get_mut(...).expect(...) → .map_or(0xFF, |p| p.state())
- lookup_psiv: .expect(...) → .ok_or(EIO)?
- port_states.get_mut().unwrap() in attach_device: 3x → .ok_or(EBADFD)?
- dev_desc.as_ref().unwrap(): 1x → .ok_or(EBADFD)?
- port_states.get().unwrap() in spawn_drivers: 1x → .ok_or(EBADFD)?
- Added EBADFD (77) import to mod.rs

85→64 total panic points (34 unwrap + 30 expect). All 27 hot-path eliminated.
Remaining 64 are cold (init/startup/regex/quirk tables) or warm (infallible
write! to String), acceptable per USB plan P1-C risk assessment.
2026-07-07 13:38:44 +03:00
..