diff options
author | Matt Carlson <mcarlson@broadcom.com> | 2010-02-26 09:04:43 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-02-28 03:43:33 -0500 |
commit | 4067a8541d397e9d6b443dd2ce0ecb78bfd991db (patch) | |
tree | 49690419b218020b8a0e9381db2f9cc90b658cd0 /drivers/net/tg3.c | |
parent | e1d5bdabb94da89bdb3c3f2ee105cf61fca88ec8 (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/tg3.c')
-rw-r--r-- | drivers/net/tg3.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index f59f36910e98..204c565caa5a 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -12586,39 +12586,33 @@ static void __devinit tg3_read_partno(struct tg3 *tp) | |||
12586 | 12586 | ||
12587 | /* Now parse and find the part number. */ | 12587 | /* Now parse and find the part number. */ |
12588 | for (i = 0; i < TG3_NVM_VPD_LEN - 2; ) { | 12588 | for (i = 0; i < TG3_NVM_VPD_LEN - 2; ) { |
12589 | unsigned int block_end; | 12589 | unsigned int block_end, rosize; |
12590 | 12590 | ||
12591 | i = pci_vpd_find_tag(vpd_data, i, TG3_NVM_VPD_LEN, | 12591 | i = pci_vpd_find_tag(vpd_data, i, TG3_NVM_VPD_LEN, |
12592 | PCI_VPD_LRDT_RO_DATA); | 12592 | PCI_VPD_LRDT_RO_DATA); |
12593 | if (i < 0) | 12593 | if (i < 0) |
12594 | break; | 12594 | break; |
12595 | 12595 | ||
12596 | block_end = i + PCI_VPD_LRDT_TAG_SIZE + | 12596 | rosize = pci_vpd_lrdt_size(&vpd_data[i]); |
12597 | pci_vpd_lrdt_size(&vpd_data[i]); | 12597 | block_end = i + PCI_VPD_LRDT_TAG_SIZE + rosize; |
12598 | |||
12599 | i += PCI_VPD_LRDT_TAG_SIZE; | 12598 | i += PCI_VPD_LRDT_TAG_SIZE; |
12600 | 12599 | ||
12601 | if (block_end > TG3_NVM_VPD_LEN) | 12600 | if (block_end > TG3_NVM_VPD_LEN) |
12602 | goto out_not_found; | 12601 | goto out_not_found; |
12603 | 12602 | ||
12604 | while (i < (block_end - 2)) { | 12603 | i = pci_vpd_find_info_keyword(vpd_data, i, rosize, |
12605 | if (vpd_data[i + 0] == 'P' && | 12604 | PCI_VPD_RO_KEYWORD_PARTNO); |
12606 | vpd_data[i + 1] == 'N') { | 12605 | if (i > 0) { |
12607 | int partno_len = pci_vpd_info_field_size(&vpd_data[i]); | 12606 | u8 len = pci_vpd_info_field_size(&vpd_data[i]); |
12608 | 12607 | ||
12609 | i += PCI_VPD_INFO_FLD_HDR_SIZE; | 12608 | i += PCI_VPD_INFO_FLD_HDR_SIZE; |
12610 | if (partno_len > TG3_BPN_SIZE || | 12609 | if (len > TG3_BPN_SIZE || |
12611 | (partno_len + i) > TG3_NVM_VPD_LEN) | 12610 | (len + i) > TG3_NVM_VPD_LEN) |
12612 | goto out_not_found; | 12611 | break; |
12613 | 12612 | ||
12614 | memcpy(tp->board_part_number, | 12613 | memcpy(tp->board_part_number, &vpd_data[i], len); |
12615 | &vpd_data[i], partno_len); | ||
12616 | 12614 | ||
12617 | /* Success. */ | 12615 | return; |
12618 | return; | ||
12619 | } | ||
12620 | i += PCI_VPD_INFO_FLD_HDR_SIZE + | ||
12621 | pci_vpd_info_field_size(&vpd_data[i]); | ||
12622 | } | 12616 | } |
12623 | 12617 | ||
12624 | /* Part number not found. */ | 12618 | /* Part number not found. */ |