aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2.c
diff options
context:
space:
mode:
authorMatt Carlson <mcarlson@broadcom.com>2010-02-26 09:04:43 -0500
committerDavid S. Miller <davem@davemloft.net>2010-02-28 03:43:33 -0500
commit4067a8541d397e9d6b443dd2ce0ecb78bfd991db (patch)
tree49690419b218020b8a0e9381db2f9cc90b658cd0 /drivers/net/bnx2.c
parente1d5bdabb94da89bdb3c3f2ee105cf61fca88ec8 (diff)
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 b808707f83ff..bc23bfb687c3 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -7769,48 +7769,54 @@ bnx2_read_vpd_fw_ver(struct bnx2 *bp)
7769 } 7769 }
7770 7770
7771 for (i = 0; i <= BNX2_VPD_LEN - 3; ) { 7771 for (i = 0; i <= BNX2_VPD_LEN - 3; ) {
7772 unsigned int block_end; 7772 int j;
7773 unsigned int block_end, rosize;
7773 7774
7774 i = pci_vpd_find_tag(data, i, BNX2_VPD_LEN, 7775 i = pci_vpd_find_tag(data, i, BNX2_VPD_LEN,
7775 PCI_VPD_LRDT_RO_DATA); 7776 PCI_VPD_LRDT_RO_DATA);
7776 if (i < 0) 7777 if (i < 0)
7777 break; 7778 break;
7778 7779
7779 block_end = (i + PCI_VPD_LRDT_TAG_SIZE + 7780 rosize = pci_vpd_lrdt_size(&data[i]);
7780 pci_vpd_lrdt_size(&data[i])); 7781 block_end = i + PCI_VPD_LRDT_TAG_SIZE + rosize;
7781 i += PCI_VPD_LRDT_TAG_SIZE; 7782 i += PCI_VPD_LRDT_TAG_SIZE;
7782 7783
7783 if (block_end > BNX2_VPD_LEN) 7784 if (block_end > BNX2_VPD_LEN)
7784 goto vpd_done; 7785 goto vpd_done;
7785 7786
7786 while (i < (block_end - 2)) { 7787 j = pci_vpd_find_info_keyword(data, i, rosize,
7787 int len = pci_vpd_info_field_size(&data[i]); 7788 PCI_VPD_RO_KEYWORD_MFR_ID);
7789 if (j > 0) {
7790 int len = pci_vpd_info_field_size(&data[j]);
7788 7791
7789 if (i + PCI_VPD_INFO_FLD_HDR_SIZE + len > block_end) 7792 if (j + PCI_VPD_INFO_FLD_HDR_SIZE + len > block_end ||
7793 len != 4 ||
7794 memcmp(&data[j + PCI_VPD_INFO_FLD_HDR_SIZE],
7795 "1028", 4))
7790 goto vpd_done; 7796 goto vpd_done;
7791 7797
7792 if (data[i] == 'M' && data[i + 1] == 'N') { 7798 mn_match = true;
7793 if (len != 4 || 7799 }
7794 memcmp(&data[i + PCI_VPD_INFO_FLD_HDR_SIZE],
7795 "1028", 4))
7796 goto vpd_done;
7797 mn_match = true;
7798 7800
7799 } else if (data[i] == 'V' && data[i + 1] == '0') { 7801 j = pci_vpd_find_info_keyword(data, i, rosize,
7800 if (len > BNX2_MAX_VER_SLEN) 7802 PCI_VPD_RO_KEYWORD_VENDOR0);
7801 goto vpd_done; 7803 if (j > 0) {
7804 int len = pci_vpd_info_field_size(&data[j]);
7802 7805
7803 v0_len = len; 7806 j += PCI_VPD_INFO_FLD_HDR_SIZE;
7804 v0_str = &data[i + PCI_VPD_INFO_FLD_HDR_SIZE]; 7807 if (j + len > block_end || len > BNX2_MAX_VER_SLEN)
7805 }
7806 i += PCI_VPD_INFO_FLD_HDR_SIZE + len;
7807
7808 if (mn_match && v0_str) {
7809 memcpy(bp->fw_version, v0_str, v0_len);
7810 bp->fw_version[v0_len] = ' ';
7811 goto vpd_done; 7808 goto vpd_done;
7812 } 7809
7810 v0_len = len;
7811 v0_str = &data[j];
7813 } 7812 }
7813
7814 if (mn_match && v0_str) {
7815 memcpy(bp->fw_version, v0_str, v0_len);
7816 bp->fw_version[v0_len] = ' ';
7817 goto vpd_done;
7818 }
7819
7814 goto vpd_done; 7820 goto vpd_done;
7815 } 7821 }
7816 7822