]> git.hungrycats.org Git - linux/commitdiff
[TG32]: Use pci_get_slot() to find 5704 peers, to handle domains properly.
authorMatthew Wilcox <willy@debian.org>
Sun, 8 Feb 2004 05:09:03 +0000 (21:09 -0800)
committerDavid S. Miller <davem@nuts.davemloft.net>
Sun, 8 Feb 2004 05:09:03 +0000 (21:09 -0800)
drivers/net/tg3.c

index f52c8fbb8451d8686f343c419b1a727b8eadf739..7dce45ddadcf0eca22d530337b66a81b620bdc39 100644 (file)
@@ -7523,23 +7523,24 @@ static char * __devinit tg3_phy_string(struct tg3 *tp)
 
 static struct pci_dev * __devinit tg3_find_5704_peer(struct tg3 *tp)
 {
-       struct pci_dev *peer = NULL;
-       unsigned int func;
+       struct pci_dev *peer;
+       unsigned int func, devnr = tp->pdev->devfn & ~7;
 
-       for (func = 0; func < 7; func++) {
-               unsigned int devfn = tp->pdev->devfn;
-
-               devfn &= ~7;
-               devfn |= func;
-
-               if (devfn == tp->pdev->devfn)
-                       continue;
-               peer = pci_find_slot(tp->pdev->bus->number, devfn);
-               if (peer)
+       for (func = 0; func < 8; func++) {
+               peer = pci_get_slot(tp->pdev->bus, devnr | func);
+               if (peer && peer != tp->pdev)
                        break;
+               pci_dev_put(peer);
        }
        if (!peer || peer == tp->pdev)
                BUG();
+
+       /*
+        * We don't need to keep the refcount elevated; there's no way
+        * to remove one half of this device without removing the other
+        */
+       pci_dev_put(peer);
+
        return peer;
 }