Skip to content

Commit

Permalink
[pci] Allow pci_vpd_init() return status to be ignored
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mcb30 committed Jan 19, 2011
1 parent 17d28f4 commit 267ef31
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/drivers/bus/pcivpd.c
Expand Up @@ -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 ) ) {
Expand Down Expand Up @@ -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 );

Expand Down
11 changes: 11 additions & 0 deletions src/include/ipxe/pcivpd.h
Expand Up @@ -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
*
Expand Down

0 comments on commit 267ef31

Please sign in to comment.