Check that the PCI device supplied is neither out of range nor does it use any reserved device ID.
(device_id: u8)
| 431 | /// Check that the PCI device supplied is neither out of range nor does |
| 432 | /// it use any reserved device ID. |
| 433 | fn validate_pci_device_id(device_id: u8) -> ValidationResult<()> { |
| 434 | if device_id >= pci::NUM_DEVICE_IDS { |
| 435 | // Check the given ID is not out of range |
| 436 | return Err(ValidationError::InvalidPciDeviceId(device_id)); |
| 437 | } else if device_id == pci::PCI_ROOT_DEVICE_ID { |
| 438 | // Check the ID isn't any reserved one. Currently, only the device ID |
| 439 | // for the root device is reserved. |
| 440 | return Err(ValidationError::ReservedPciDeviceId(device_id)); |
| 441 | } |
| 442 | |
| 443 | Ok(()) |
| 444 | } |
| 445 | |
| 446 | pub type Result<T> = result::Result<T, Error>; |
| 447 |