unsigned int block_end;
if (val == 0x82 || val == 0x91) {
- i = (i + 3 + (data[i + 1] + (data[i + 2] << 8)));
+ i += PCI_VPD_LRDT_TAG_SIZE +
+ pci_vpd_lrdt_size(&data[i]);
continue;
}
if (val != 0x90)
goto vpd_done;
- block_end = (i + 3 + (data[i + 1] + (data[i + 2] << 8)));
- i += 3;
+ block_end = (i + PCI_VPD_LRDT_TAG_SIZE +
+ pci_vpd_lrdt_size(&data[i]));
+ i += PCI_VPD_LRDT_TAG_SIZE;
if (block_end > BNX2_VPD_LEN)
goto vpd_done;
unsigned int block_end;
if (val == 0x82 || val == 0x91) {
- i = (i + 3 +
- (vpd_data[i + 1] +
- (vpd_data[i + 2] << 8)));
+ i += PCI_VPD_LRDT_TAG_SIZE +
+ pci_vpd_lrdt_size(&vpd_data[i]);
continue;
}
if (val != 0x90)
goto out_not_found;
- block_end = (i + 3 +
- (vpd_data[i + 1] +
- (vpd_data[i + 2] << 8)));
- i += 3;
+ block_end = i + PCI_VPD_LRDT_TAG_SIZE +
+ pci_vpd_lrdt_size(&vpd_data[i]);
+
+ i += PCI_VPD_LRDT_TAG_SIZE;
if (block_end > TG3_NVM_VPD_LEN)
goto out_not_found;
void pci_request_acs(void);
+
+#define PCI_VPD_LRDT_TAG_SIZE 3
+
+/**
+ * pci_vpd_lrdt_size - Extracts the Large Resource Data Type length
+ * @lrdt: Pointer to the beginning of the Large Resource Data Type tag
+ *
+ * Returns the extracted Large Resource Data Type length.
+ */
+static inline u16 pci_vpd_lrdt_size(const u8 *lrdt)
+{
+ return (u16)lrdt[1] + ((u16)lrdt[2] << 8);
+}
+
#endif /* __KERNEL__ */
#endif /* LINUX_PCI_H */