pci <-> device node mapping

Todd Inglett tinglett at vnet.ibm.com
Mon Jun 23 23:41:47 EST 2003

On Fri, 2003-06-20 at 17:14, linas at austin.ibm.com wrote:
> Linda Xie over here is doing some device driver work, where she gets
> an RTAS event with a firmware location code in it.  Based on the location
> code, she wants to be able to find the corresponding pci_dev structure.
> What's the best way to do this?

This is nearly trivial in the current implementation by observing the
subject of this thread :).  Loop through the pci_dev's and do this for
each one until you get a hit:

	struct device_node *dn = pci_device_to_OF_node(dev);

 	if (dev) {
		char *loc = (char *)get_property(dn, "ibm,loc-code", 0);
		if (loc && strcmp(loc, myloc_code) == 0)
			return dev;

I think Greg KH recently eliminated pci_for_each_dev in 2.5 so you'll
have to iterate with another mechanism.  IIRC, he patched everything to
iterate with pci_find_device() so you might do the same.
Todd Inglett <tinglett at vnet.ibm.com>

** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/

More information about the Linuxppc64-dev mailing list