* RE: find struct pci_dev from struct net_device
@ 2001-09-13 9:22 Hen, Shmulik
2001-09-13 9:41 ` David Woodhouse
0 siblings, 1 reply; 5+ messages in thread
From: Hen, Shmulik @ 2001-09-13 9:22 UTC (permalink / raw)
To: 'Sebastian Heidl', linux-kernel
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/
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: find struct pci_dev from struct net_device
2001-09-13 9:22 find struct pci_dev from struct net_device Hen, Shmulik
@ 2001-09-13 9:41 ` David Woodhouse
0 siblings, 0 replies; 5+ messages in thread
From: David Woodhouse @ 2001-09-13 9:41 UTC (permalink / raw)
To: Hen, Shmulik; +Cc: 'Sebastian Heidl', linux-kernel
shmulik.hen@intel.com said:
> 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:
We have to assume this isn't a deliberate attempt to mislead, and that you
really do things like this in your own code.
I suspect that whatever chance there was of someone trying to help out some
poor user unfortunate or ignorant enough to use the binary-only modules that
you are working on has just bitten the dust.
--
dwmw2
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: find struct pci_dev from struct net_device
@ 2001-09-13 10:34 Hen, Shmulik
0 siblings, 0 replies; 5+ messages in thread
From: Hen, Shmulik @ 2001-09-13 10:34 UTC (permalink / raw)
To: 'David Woodhouse'; +Cc: linux-kernel
Just trying to repent by contributing something good back to the community
;-)
Actually, I'm using this exact code and in an open source project too (we
have those too you know).
-----Original Message-----
From: David Woodhouse [mailto:dwmw2@infradead.org]
Sent: Thursday, September 13, 2001 12:42 PM
To: Hen, Shmulik
Cc: 'Sebastian Heidl'; linux-kernel@vger.kernel.org
Subject: Re: find struct pci_dev from struct net_device
shmulik.hen@intel.com said:
> 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:
We have to assume this isn't a deliberate attempt to mislead, and that you
really do things like this in your own code.
I suspect that whatever chance there was of someone trying to help out some
poor user unfortunate or ignorant enough to use the binary-only modules that
you are working on has just bitten the dust.
--
dwmw2
^ permalink raw reply [flat|nested] 5+ messages in thread
* find struct pci_dev from struct net_device
@ 2001-09-12 12:52 Sebastian Heidl
2001-09-13 12:10 ` Francois Romieu
0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Heidl @ 2001-09-12 12:52 UTC (permalink / raw)
To: linux-kernel
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_
--
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: find struct pci_dev from struct net_device
2001-09-12 12:52 Sebastian Heidl
@ 2001-09-13 12:10 ` Francois Romieu
0 siblings, 0 replies; 5+ messages in thread
From: Francois Romieu @ 2001-09-13 12:10 UTC (permalink / raw)
To: Sebastian Heidl; +Cc: linux-kernel
Sebastian Heidl <heidl@zib.de> :
> 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) ?
Forget it. It depends on the driver in both directions. How would it
handle a pci device with different L2 interfaces or a network adapter
with PCI bridge + various PCI devices behind the bridge ?
--
Ueimor
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2001-09-13 12:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-09-13 9:22 find struct pci_dev from struct net_device Hen, Shmulik
2001-09-13 9:41 ` David Woodhouse
-- strict thread matches above, loose matches on Subject: below --
2001-09-13 10:34 Hen, Shmulik
2001-09-12 12:52 Sebastian Heidl
2001-09-13 12:10 ` Francois Romieu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox