diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/drivers/bus/pcivpd.c | 8 | ||||
| -rw-r--r-- | src/include/ipxe/pcivpd.h | 11 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/drivers/bus/pcivpd.c b/src/drivers/bus/pcivpd.c index 1f7d832b9..1ee6c6415 100644 --- a/src/drivers/bus/pcivpd.c +++ b/src/drivers/bus/pcivpd.c @@ -73,6 +73,10 @@ static int pci_vpd_read_dword ( struct pci_vpd *vpd, int address, unsigned int retries; uint16_t flag; + /* Fail if no VPD present */ + if ( ! cap ) + return -ENOTTY; + /* Return cached value, if present */ if ( pci_vpd_cache_is_valid ( vpd ) && ( vpd->cache.address == address ) ) { @@ -127,6 +131,10 @@ static int pci_vpd_write_dword ( struct pci_vpd *vpd, int address, unsigned int retries; uint16_t flag; + /* Fail if no VPD present */ + if ( ! cap ) + return -ENOTTY; + /* Invalidate cache */ pci_vpd_invalidate_cache ( vpd ); diff --git a/src/include/ipxe/pcivpd.h b/src/include/ipxe/pcivpd.h index 8b973ea1c..469ec29f8 100644 --- a/src/include/ipxe/pcivpd.h +++ b/src/include/ipxe/pcivpd.h @@ -134,6 +134,17 @@ struct pci_vpd { }; /** + * Check for presence of PCI VPD + * + * @v vpd PCI VPD + * @ret is_present VPD is present + */ +static inline __attribute__ (( always_inline )) int +pci_vpd_is_present ( struct pci_vpd *vpd ) { + return ( vpd->cap != 0 ); +} + +/** * Check if PCI VPD read cache is valid * * @v vpd PCI VPD |
