]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[pci] Allow pci_vpd_init() return status to be ignored
authorMichael Brown <mcb30@ipxe.org>
Tue, 11 Jan 2011 01:37:27 +0000 (01:37 +0000)
committerMichael Brown <mcb30@ipxe.org>
Wed, 19 Jan 2011 13:52:55 +0000 (13:52 +0000)
Most xxx_init() functions are void functions with no failure cases.
Allow pci_vpd_init() to be used in the same way.  (Subsequent calls to
pci_vpd_read() etc. will fail if pci_vpd_init() fails.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/bus/pcivpd.c
src/include/ipxe/pcivpd.h

index 1f7d832b90b0086fb6d7717b5961f4c8b446c685..1ee6c6415aee7e24d5506d4a884c0e6562915060 100644 (file)
@@ -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 );
 
index 8b973ea1c15e2674dcda5efc43ecab84c7b74940..469ec29f884cdbd59c0f5b977567b46cb1e0c866 100644 (file)
@@ -133,6 +133,17 @@ struct pci_vpd {
        struct pci_vpd_cache cache;
 };
 
+/**
+ * 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
  *