use crate::PCI;
pub(super) fn parse_pcidebug(pcidebug: &str) -> Option<PCI> {
let (address, _) = pcidebug.split_once('(').unwrap_or((pcidebug, ""));
let mut parts = address.split(':');
let bus: u8 = parts.next()?.parse().ok()?;
let device: u8 = parts.next()?.parse().ok()?;
let function: u8 = parts.next()?.parse().ok()?;
if device > 0x1f {
return None;
}
if function > 0x07 {
return None;
}
Some(PCI {
domain: 0,
bus: bus as u32,
device: device as u32,
function: function as u32,
})
}