Browse Source

[pci] Allow pci_vpd_init() return status to be ignored

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>
tags/v1.20.1
Michael Brown 13 years ago
parent
commit
267ef31791
2 changed files with 19 additions and 0 deletions
  1. 8
    0
      src/drivers/bus/pcivpd.c
  2. 11
    0
      src/include/ipxe/pcivpd.h

+ 8
- 0
src/drivers/bus/pcivpd.c View File

73
 	unsigned int retries;
73
 	unsigned int retries;
74
 	uint16_t flag;
74
 	uint16_t flag;
75
 
75
 
76
+	/* Fail if no VPD present */
77
+	if ( ! cap )
78
+		return -ENOTTY;
79
+
76
 	/* Return cached value, if present */
80
 	/* Return cached value, if present */
77
 	if ( pci_vpd_cache_is_valid ( vpd ) &&
81
 	if ( pci_vpd_cache_is_valid ( vpd ) &&
78
 	     ( vpd->cache.address == address ) ) {
82
 	     ( vpd->cache.address == address ) ) {
127
 	unsigned int retries;
131
 	unsigned int retries;
128
 	uint16_t flag;
132
 	uint16_t flag;
129
 
133
 
134
+	/* Fail if no VPD present */
135
+	if ( ! cap )
136
+		return -ENOTTY;
137
+
130
 	/* Invalidate cache */
138
 	/* Invalidate cache */
131
 	pci_vpd_invalidate_cache ( vpd );
139
 	pci_vpd_invalidate_cache ( vpd );
132
 
140
 

+ 11
- 0
src/include/ipxe/pcivpd.h View File

133
 	struct pci_vpd_cache cache;
133
 	struct pci_vpd_cache cache;
134
 };
134
 };
135
 
135
 
136
+/**
137
+ * Check for presence of PCI VPD
138
+ *
139
+ * @v vpd		PCI VPD
140
+ * @ret is_present	VPD is present
141
+ */
142
+static inline __attribute__ (( always_inline )) int
143
+pci_vpd_is_present ( struct pci_vpd *vpd ) {
144
+	return ( vpd->cap != 0 );
145
+}
146
+
136
 /**
147
 /**
137
  * Check if PCI VPD read cache is valid
148
  * Check if PCI VPD read cache is valid
138
  *
149
  *

Loading…
Cancel
Save