diff --git a/local/recipes/drivers/redox-driver-sys/source/src/quirks/mod.rs b/local/recipes/drivers/redox-driver-sys/source/src/quirks/mod.rs index e282159690..0686323cdb 100644 --- a/local/recipes/drivers/redox-driver-sys/source/src/quirks/mod.rs +++ b/local/recipes/drivers/redox-driver-sys/source/src/quirks/mod.rs @@ -764,6 +764,6 @@ bitflags::bitflags! { } /// Look up USB HID quirks for a vendor/product pair. -pub fn lookup_hid_quirks(vendor: u16, _product: u16) -> HidQuirkFlags { +pub fn lookup_hid_quirks(_vendor: u16, _product: u16) -> HidQuirkFlags { HidQuirkFlags::empty() } diff --git a/local/recipes/system/udev-shim/source/src/device_db.rs b/local/recipes/system/udev-shim/source/src/device_db.rs index 985005367e..e238b56f16 100644 --- a/local/recipes/system/udev-shim/source/src/device_db.rs +++ b/local/recipes/system/udev-shim/source/src/device_db.rs @@ -33,6 +33,7 @@ pub struct DeviceInfo { pub devnode: String, pub scheme_target: String, pub symlinks: Vec, + pub driver: Option, } impl DeviceInfo { @@ -59,6 +60,7 @@ impl DeviceInfo { devnode: devnode.to_string(), scheme_target: scheme_target.to_string(), symlinks: Vec::new(), + driver: None, } } @@ -167,6 +169,7 @@ pub fn classify_pci_device(bus: u8, dev: u8, func: u8) -> DeviceInfo { devnode: String::new(), scheme_target: String::new(), symlinks: Vec::new(), + driver: None, } } @@ -330,6 +333,7 @@ mod tests { devnode: String::new(), scheme_target: String::new(), symlinks: vec![], + driver: None, }; assert_eq!(dev.id_path(), "pci-0000:02:00.0"); } @@ -392,6 +396,7 @@ mod tests { devnode: "/dev/dri/card0".to_string(), scheme_target: "display:display".to_string(), symlinks: vec![], + driver: None, }; let props = device_properties(&dev); let prop_map: std::collections::HashMap<&str, &str> = props @@ -464,6 +469,7 @@ mod tests { devnode: "/dev/dri/card0".to_string(), scheme_target: "display:display".to_string(), symlinks: vec!["/dev/dri/by-path/pci-0000:02:00.0-card".to_string()], + driver: None, }; let info = format_device_info(&dev); assert!(info.starts_with("P=/devices/pci/0000:02:00.0\n")); @@ -531,6 +537,9 @@ pub fn device_properties(dev: &DeviceInfo) -> Vec<(String, String)> { "PCI_CLASS".to_string(), format!("0x{:02x}{:02x}", dev.class_code, dev.subclass), )); + if let Some(driver) = &dev.driver { + props.push(("DRIVER".to_string(), driver.clone())); + } } if dev.subsystem == Subsystem::Input { diff --git a/local/recipes/system/udev-shim/source/src/scheme.rs b/local/recipes/system/udev-shim/source/src/scheme.rs index a12089c637..20d82ef54b 100644 --- a/local/recipes/system/udev-shim/source/src/scheme.rs +++ b/local/recipes/system/udev-shim/source/src/scheme.rs @@ -1,4 +1,4 @@ -use std::collections::BTreeMap; +use std::collections::{BTreeMap, HashMap}; use std::fs::File; use std::io::Read; @@ -104,9 +104,16 @@ impl UdevScheme { } } + let driver_map = read_driver_manager_bound(); + pci_slots.sort_unstable(); for (bus, dev, func) in pci_slots { - self.devices.push(classify_pci_device(bus, dev, func)); + let mut info = classify_pci_device(bus, dev, func); + let slot_str = format!("{:04}--{:02}--{:02}.{}", 0, bus, dev, func); + if let Some(driver) = driver_map.get(&slot_str) { + info.driver = Some(driver.clone()); + } + self.devices.push(info); } if scheme_registered("input") { @@ -810,3 +817,23 @@ fn storage_symlink(dev: &DeviceInfo, kernel_name: &str) -> Option { fn content_len_u64(content: String) -> u64 { u64::try_from(content.len()).unwrap_or(u64::MAX) } + +fn read_driver_manager_bound() -> HashMap { + let mut map = HashMap::new(); + match std::fs::read_to_string("/scheme/driver-manager/bound") { + Ok(body) => { + for line in body.lines() { + let line = line.trim(); + if line.is_empty() { + continue; + } + let parts: Vec<&str> = line.splitn(2, " -> ").collect(); + if parts.len() == 2 { + map.insert(parts[0].to_string(), parts[1].to_string()); + } + } + } + Err(_) => {} + } + map +}