]> 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 f204f73c4f99cb0edc0a7939c67ae365b6c1a8a8..76ad141ab448ea5b32f59694ff507460b1760ce6 100644 (file)
@@ -9458,15 +9458,12 @@ static void __tg3_set_rx_mode(struct net_device *dev)
        } else {
                /* Accept one or more multicast(s). */
                struct dev_mc_list *mclist;
-               unsigned int i;
                u32 mc_filter[4] = { 0, };
                u32 regidx;
                u32 bit;
                u32 crc;
 
-               for (i = 0, mclist = dev->mc_list; mclist && i < netdev_mc_count(dev);
-                    i++, mclist = mclist->next) {
-
+               netdev_for_each_mc_addr(mclist, dev) {
                        crc = calc_crc (mclist->dmi_addr, ETH_ALEN);
                        bit = ~crc & 0x7f;
                        regidx = (bit & 0x60) >> 5;
@@ -12550,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) ||
@@ -12589,23 +12586,17 @@ 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 == 0x82 || val == 0x91) {
-                       i = (i + 3 +
-                            (vpd_data[i + 1] +
-                             (vpd_data[i + 2] << 8)));
-                       continue;
-               }
+               i = pci_vpd_find_tag(vpd_data, i, TG3_NVM_VPD_LEN,
+                                    PCI_VPD_LRDT_RO_DATA);
+               if (i < 0)
+                       break;
 
-               if (val != 0x90)
-                       goto out_not_found;
+               block_end = i + PCI_VPD_LRDT_TAG_SIZE +
+                           pci_vpd_lrdt_size(&vpd_data[i]);
 
-               block_end = (i + 3 +
-                            (vpd_data[i + 1] +
-                             (vpd_data[i + 2] << 8)));
-               i += 3;
+               i += PCI_VPD_LRDT_TAG_SIZE;
 
                if (block_end > TG3_NVM_VPD_LEN)
                        goto out_not_found;