Pārlūkot izejas kodu

[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 14 gadus atpakaļ
vecāks
revīzija
267ef31791
2 mainītis faili ar 19 papildinājumiem un 0 dzēšanām
  1. 8
    0
      src/drivers/bus/pcivpd.c
  2. 11
    0
      src/include/ipxe/pcivpd.h

+ 8
- 0
src/drivers/bus/pcivpd.c Parādīt failu

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

+ 11
- 0
src/include/ipxe/pcivpd.h Parādīt failu

@@ -133,6 +133,17 @@ struct pci_vpd {
133 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 148
  * Check if PCI VPD read cache is valid
138 149
  *

Notiek ielāde…
Atcelt
Saglabāt