diff --git a/pcid/src/config.rs b/pcid/src/config.rs index 8a36d8df1d..ee7756c82e 100644 --- a/pcid/src/config.rs +++ b/pcid/src/config.rs @@ -11,6 +11,7 @@ pub struct DriverConfig { pub class: Option, pub subclass: Option, pub interface: Option, + pub ids: Option>>, pub vendor: Option, pub device: Option, pub device_id_range: Option>, diff --git a/pcid/src/main.rs b/pcid/src/main.rs index 2c247cdfda..bf5581fc0d 100644 --- a/pcid/src/main.rs +++ b/pcid/src/main.rs @@ -7,7 +7,7 @@ extern crate byteorder; extern crate syscall; extern crate toml; -use std::env; +use std::{env, i64}; use std::fs::{File, metadata, read_dir}; use std::io::Read; use std::process::Command; @@ -80,12 +80,30 @@ fn handle_parsed_header(config: &Config, pci: &Pci, bus_num: u8, if interface != header.interface() { continue; } } - if let Some(vendor) = driver.vendor { - if vendor != header.vendor_id() { continue; } - } + if let Some(ref ids) = driver.ids { + let mut device_found = false; + for (vendor, devices) in ids { + let vendor_without_prefix = vendor.trim_left_matches("0x"); + let vendor = i64::from_str_radix(vendor_without_prefix, 16).unwrap() as u16; - if let Some(device) = driver.device { - if device != header.device_id() { continue; } + if vendor != header.vendor_id() { continue; } + + for device in devices { + if *device == header.device_id() { + device_found = true; + break; + } + } + } + if !device_found { continue; } + } else { + if let Some(vendor) = driver.vendor { + if vendor != header.vendor_id() { continue; } + } + + if let Some(device) = driver.device { + if device != header.device_id() { continue; } + } } if let Some(ref device_id_range) = driver.device_id_range {