From 3783ad83e4a96c83d49c922122191d2304bae0a5 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Sat, 7 Feb 2004 21:09:03 -0800 Subject: [PATCH] [TG32]: Use pci_get_slot() to find 5704 peers, to handle domains properly. --- drivers/net/tg3.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index f52c8fbb8451d..7dce45ddadcf0 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -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; } -- 2.53.0