/*
- * $Id: generic.c,v 1.6 2000/04/21 11:58:00 mj Exp $
- *
* The PCI Library -- Generic Direct Access Functions
*
- * Copyright (c) 1997--2000 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ * Copyright (c) 1997--2000 Martin Mares <mj@ucw.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
pci_generic_scan_bus(struct pci_access *a, byte *busmap, int bus)
{
int dev, multi, ht;
- struct pci_dev *t = pci_alloc_dev(a);
+ struct pci_dev *t;
a->debug("Scanning bus %02x for devices...\n", bus);
if (busmap[bus])
return;
}
busmap[bus] = 1;
+ t = pci_alloc_dev(a);
t->bus = bus;
for(dev=0; dev<32; dev++)
{
t->dev = dev;
multi = 0;
- for(t->func=0; t->func<8; t->func++)
+ for(t->func=0; !t->func || multi && t->func<8; t->func++)
{
u32 vd = pci_read_long(t, PCI_VENDOR_ID);
struct pci_dev *d;
if (!vd || vd == 0xffffffff)
- break;
+ continue;
ht = pci_read_byte(t, PCI_HEADER_TYPE);
if (!t->func)
multi = ht & 0x80;
default:
a->debug("Device %02x:%02x.%d has unknown header type %02x.\n", d->bus, d->dev, d->func, ht);
}
- if (!multi)
- break;
}
}
+ pci_free_dev(t);
}
void