]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - drivers/net/tg3.c
pci: Add helper to find a VPD resource data type
[net-next-2.6.git] / drivers / net / tg3.c
index ed57a62b3ac86f0a48cb6a0723ba1ffc14c9a735..76ad141ab448ea5b32f59694ff507460b1760ce6 100644 (file)
@@ -12547,7 +12547,7 @@ skip_phy_reset:
 static void __devinit tg3_read_partno(struct tg3 *tp)
 {
        unsigned char vpd_data[TG3_NVM_VPD_LEN];   /* in little-endian format */
-       unsigned int i;
+       int i;
        u32 magic;
 
        if ((tp->tg3_flags3 & TG3_FLG3_NO_NVRAM) ||
@@ -12586,28 +12586,12 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
 
        /* Now parse and find the part number. */
        for (i = 0; i < TG3_NVM_VPD_LEN - 2; ) {
-               unsigned char val = vpd_data[i];
                unsigned int block_end;
 
-               if (val & PCI_VPD_LRDT) {
-                       if (i + PCI_VPD_LRDT_TAG_SIZE > TG3_NVM_VPD_LEN)
-                               break;
-
-                       if (val != PCI_VPD_LRDT_RO_DATA) {
-                               i += PCI_VPD_LRDT_TAG_SIZE +
-                                    pci_vpd_lrdt_size(&vpd_data[i]);
-
-                               continue;
-                       }
-               } else {
-                       if ((val & PCI_VPD_SRDT_TIN_MASK) == PCI_VPD_STIN_END)
-                               break;
-
-                       i += PCI_VPD_SRDT_TAG_SIZE +
-                            pci_vpd_srdt_size(&vpd_data[i]);
-
-                       continue;
-               }
+               i = pci_vpd_find_tag(vpd_data, i, TG3_NVM_VPD_LEN,
+                                    PCI_VPD_LRDT_RO_DATA);
+               if (i < 0)
+                       break;
 
                block_end = i + PCI_VPD_LRDT_TAG_SIZE +
                            pci_vpd_lrdt_size(&vpd_data[i]);