RE: find struct pci_dev from struct net_device

Hen, Shmulik (shmulik.hen@intel.com)
Thu, 13 Sep 2001 12:22:47 +0300


Take the value of dev->base_addr, mask it's lowest 4 bits, do a scan of all
PCI net devices and in each PCI device try to match to each of the 6 address
regs:

struct pci_dev* find_pci_device_by_baseddr(unsigned long base_addr)
{
struct pci_dev *pcid = NULL;
unsigned long reg;
int i;

base_addr &= ~(0x0000000F);

while ((pcid = pci_find_class(PCI_CLASS_NETWORK_ETHERNET << 8, pcid)))
{
for (i=0; i<6; i++) {
reg = pci_resource_start(pcid,i);
reg &= ~(0x0000000F);
if (reg == base_addr) {
return pcid;
}
}
}

return NULL;
}
-----Original Message-----
From: Sebastian Heidl [mailto:heidl@zib.de]
Sent: Wednesday, September 12, 2001 3:53 PM
To: linux-kernel@vger.kernel.org
Subject: find struct pci_dev from struct net_device

Hi,

What's the easiest way to find a corresponding struct pci_dev from a
struct net_device ? Especially, if the driver does not set
pci_dev.driver_data to it's net_device struct (such as the acenic
driver) ?

thanks,
_sh_

-- 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/