Subject: Re: looking for devices on PCI bus
To: Manuel Bouyer <>
From: None <>
List: tech-kern
Date: 05/01/2001 15:08:09
You might want to check out QNX for how they do this.  They have a similar
routine (can't remember it off the top of my head, but I can find it later
if desired).  I'm not saying their way is better or best, but it's worth
looking at for ideas I think.


On Tue, 1 May 2001, Manuel Bouyer wrote:

>there is at last 2 situations where we want to look for PCI devices of a
>given type in the system. The first one is for LKM device driver (we
>need to find the devices we can drive at lkm load time), the second is for
>pciide (where I need to find which pcib we have to know the exact type of
>VIA IDE controller). For now the only way to do this would be to duplicate
>part of pci.c in various drivers which need it, so I think it's time to come
>with a generic way of doing this.
>The interface I'm thinking of could be something like:
>pci_find_device_by_id(bus, vendor, id, rev, callback(struct pci_attach_args *))
>This would scan PCI busses in the system. "bus" would be the pci bus number,
>"vendor", "id", "rev" the PCI vendor, device, and revision ID.
>Each of theses could be set to '-1' meaning wildcard.
>For each device matching found "callback()" would be invoked.
>In a similar way we could have a pci_find_device_by_class to
>find devices of a specific call/subclass:
>pci_find_device_by_id(bus, class, subclass, callback(struct pci_attach_args *))
>The code needed for this would be quite small, most of it is already there
>for autoconf stuff.
>Comments ?
>If nobody object to adding these functions, I'll propose an implementation
>Manuel Bouyer <>