summaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2.c
diff options
context:
space:
mode:
authorMatt Carlson <mcarlson@broadcom.com>2010-02-26 14:04:43 +0000
committerDavid S. Miller <davem@davemloft.net>2010-02-28 00:43:33 -0800
commit4067a8541d397e9d6b443dd2ce0ecb78bfd991db (patch)
tree49690419b218020b8a0e9381db2f9cc90b658cd0 /drivers/net/bnx2.c
parente1d5bdabb94da89bdb3c3f2ee105cf61fca88ec8 (diff)
downloadop-kernel-dev-4067a8541d397e9d6b443dd2ce0ecb78bfd991db.zip
op-kernel-dev-4067a8541d397e9d6b443dd2ce0ecb78bfd991db.tar.gz
pci: Add helper to search for VPD keywords
This patch adds the pci_vpd_find_info_keyword() helper function to find information field keywords within read-only and read-write large resource data type sections. Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Signed-off-by: Michael Chan <mchan@broadcom.com> Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2.c')
-rw-r--r--drivers/net/bnx2.c54
1 files changed, 30 insertions, 24 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index b808707..bc23bfb 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -7769,48 +7769,54 @@ bnx2_read_vpd_fw_ver(struct bnx2 *bp)
}
for (i = 0; i <= BNX2_VPD_LEN - 3; ) {
- unsigned int block_end;
+ int j;
+ unsigned int block_end, rosize;
i = pci_vpd_find_tag(data, i, BNX2_VPD_LEN,
PCI_VPD_LRDT_RO_DATA);
if (i < 0)
break;
- block_end = (i + PCI_VPD_LRDT_TAG_SIZE +
- pci_vpd_lrdt_size(&data[i]));
+ rosize = pci_vpd_lrdt_size(&data[i]);
+ block_end = i + PCI_VPD_LRDT_TAG_SIZE + rosize;
i += PCI_VPD_LRDT_TAG_SIZE;
if (block_end > BNX2_VPD_LEN)
goto vpd_done;
- while (i < (block_end - 2)) {
- int len = pci_vpd_info_field_size(&data[i]);
+ j = pci_vpd_find_info_keyword(data, i, rosize,
+ PCI_VPD_RO_KEYWORD_MFR_ID);
+ if (j > 0) {
+ int len = pci_vpd_info_field_size(&data[j]);
- if (i + PCI_VPD_INFO_FLD_HDR_SIZE + len > block_end)
+ if (j + PCI_VPD_INFO_FLD_HDR_SIZE + len > block_end ||
+ len != 4 ||
+ memcmp(&data[j + PCI_VPD_INFO_FLD_HDR_SIZE],
+ "1028", 4))
goto vpd_done;
- if (data[i] == 'M' && data[i + 1] == 'N') {
- if (len != 4 ||
- memcmp(&data[i + PCI_VPD_INFO_FLD_HDR_SIZE],
- "1028", 4))
- goto vpd_done;
- mn_match = true;
+ mn_match = true;
+ }
- } else if (data[i] == 'V' && data[i + 1] == '0') {
- if (len > BNX2_MAX_VER_SLEN)
- goto vpd_done;
+ j = pci_vpd_find_info_keyword(data, i, rosize,
+ PCI_VPD_RO_KEYWORD_VENDOR0);
+ if (j > 0) {
+ int len = pci_vpd_info_field_size(&data[j]);
- v0_len = len;
- v0_str = &data[i + PCI_VPD_INFO_FLD_HDR_SIZE];
- }
- i += PCI_VPD_INFO_FLD_HDR_SIZE + len;
-
- if (mn_match && v0_str) {
- memcpy(bp->fw_version, v0_str, v0_len);
- bp->fw_version[v0_len] = ' ';
+ j += PCI_VPD_INFO_FLD_HDR_SIZE;
+ if (j + len > block_end || len > BNX2_MAX_VER_SLEN)
goto vpd_done;
- }
+
+ v0_len = len;
+ v0_str = &data[j];
}
+
+ if (mn_match && v0_str) {
+ memcpy(bp->fw_version, v0_str, v0_len);
+ bp->fw_version[v0_len] = ' ';
+ goto vpd_done;
+ }
+
goto vpd_done;
}
OpenPOWER on IntegriCloud