summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/powerpc/mvme5500/pci/pcifinddevice.c
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/lib/libbsp/powerpc/mvme5500/pci/pcifinddevice.c')
-rw-r--r--c/src/lib/libbsp/powerpc/mvme5500/pci/pcifinddevice.c71
1 files changed, 31 insertions, 40 deletions
diff --git a/c/src/lib/libbsp/powerpc/mvme5500/pci/pcifinddevice.c b/c/src/lib/libbsp/powerpc/mvme5500/pci/pcifinddevice.c
index 493388a86b..9f3aceec21 100644
--- a/c/src/lib/libbsp/powerpc/mvme5500/pci/pcifinddevice.c
+++ b/c/src/lib/libbsp/powerpc/mvme5500/pci/pcifinddevice.c
@@ -15,16 +15,6 @@
static int BSP_pciDebug=0;
-int BSP_pciFindDevicePrint(unsigned short vendorid, unsigned short deviceid,
- int instance, int *pbus, int *pdev, int *pfun )
-{
- BSP_pciDebug = 1;
- (void) pci_find_device(vendorid, deviceid, instance, pbus, pdev, pfun );
- BSP_pciDebug = 0;
-
- return 0;
-}
-
int pci_find_device( unsigned short vendorid, unsigned short deviceid,
int instance, int *pbus, int *pdev, int *pfun )
{
@@ -33,37 +23,38 @@ int pci_find_device( unsigned short vendorid, unsigned short deviceid,
unsigned char bus,dev,fun,hd;
for (bus=0; bus<BSP_MAX_PCI_BUS; bus++) {
- for (dev=0; dev<PCI_MAX_DEVICES; dev++) {
- pci_read_config_byte(bus, dev, 0, PCI_HEADER_TYPE, &hd);
- hd = (hd & PCI_HEADER_TYPE_MULTI_FUNCTION ? PCI_MAX_FUNCTIONS : 1);
- for (fun=0; fun<hd; fun++) {
- /*
- * The last devfn id/slot is special; must skip it
- */
- if (PCI_MAX_DEVICES-1==dev && PCI_MAX_FUNCTIONS-1 == fun)
- break;
- (void)pci_read_config_dword(bus,dev,fun,PCI_VENDOR_ID,&d);
- if (PCI_INVALID_VENDORDEVICEID == d)
- continue;
- if (BSP_pciDebug) {
- printk("pci_find_device: found 0x%08x at %2d/%2d/%2d ",d,bus,dev,fun);
- printk("(Physically: PCI%d %2d/%2d/%2d)\n",
- (bus>= BSP_MAX_PCI_BUS_ON_PCI0)? 1:0,
- (bus>= BSP_MAX_PCI_BUS_ON_PCI0)? bus-BSP_MAX_PCI_BUS_ON_PCI0:bus,
- dev, fun);
- }
-
- (void)pci_read_config_word(bus,dev,fun,PCI_VENDOR_ID,&s);
- if (vendorid != s)
- continue;
- (void)pci_read_config_word(bus,dev,fun,PCI_DEVICE_ID,&s);
- if (deviceid == s) {
- if (instance--) continue;
- *pbus=bus; *pdev=dev; *pfun=fun;
- return 0;
- }
- }
+ for (dev=0; dev<PCI_MAX_DEVICES; dev++) {
+ pci_read_config_byte(bus, dev, 0, PCI_HEADER_TYPE, &hd);
+ hd = (hd & PCI_HEADER_TYPE_MULTI_FUNCTION ? PCI_MAX_FUNCTIONS : 1);
+ for (fun=0; fun<hd; fun++) {
+ /*
+ * The last devfn id/slot is special; must skip it
+ */
+ if (PCI_MAX_DEVICES-1==dev && PCI_MAX_FUNCTIONS-1 == fun)
+ break;
+ (void)pci_read_config_dword(bus,dev,fun,PCI_VENDOR_ID,&d);
+ if (PCI_INVALID_VENDORDEVICEID == d)
+ continue;
+ if (BSP_pciDebug) {
+ printk(
+ "pci_find_device: found 0x%08x at %2d/%2d/%2d ",d,bus,dev,fun);
+ printk("(Physically: PCI%d %2d/%2d/%2d)\n",
+ (bus>= BSP_MAX_PCI_BUS_ON_PCI0)? 1:0,
+ (bus>= BSP_MAX_PCI_BUS_ON_PCI0)? bus-BSP_MAX_PCI_BUS_ON_PCI0:bus,
+ dev, fun);
+ }
+
+ (void)pci_read_config_word(bus,dev,fun,PCI_VENDOR_ID,&s);
+ if (vendorid != s)
+ continue;
+ (void)pci_read_config_word(bus,dev,fun,PCI_DEVICE_ID,&s);
+ if (deviceid == s) {
+ if (instance--) continue;
+ *pbus=bus; *pdev=dev; *pfun=fun;
+ return 0;
+ }
}
+ }
} /* end for bus */
return -1;
}