summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2000-09-03 08:30:10 +0000
committerpeter <peter@FreeBSD.org>2000-09-03 08:30:10 +0000
commit1ea926e93d79bf4e3ce719a70f2f95901226ab9f (patch)
treef56971f27659c079955864e9be1a1eccbaf29765
parent175e5fe4dd448cce6e48db6f1b026da149b5d9ff (diff)
downloadFreeBSD-src-1ea926e93d79bf4e3ce719a70f2f95901226ab9f.zip
FreeBSD-src-1ea926e93d79bf4e3ce719a70f2f95901226ab9f.tar.gz
Fix pci-pci bridges (I hope).
In the nexus case, there are no ivars for children of nexus devices, and we were passing data in from before the device existed, hence ivars are convenient as the softc doesn't really exist yet. However, for pci->pci bridges, the pcib occupies a pci device itself, which *does* already have ivars. However, softc is available and stable at this point since we've been identified and are locating the bus during attach. So, use softc for this version of pcib devices for storing the physical bus number in.
-rw-r--r--sys/pci/pcisupport.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/sys/pci/pcisupport.c b/sys/pci/pcisupport.c
index 0595dce..1f2e328 100644
--- a/sys/pci/pcisupport.c
+++ b/sys/pci/pcisupport.c
@@ -760,18 +760,13 @@ static int pcib_attach(device_t dev)
{
u_int8_t secondary;
device_t child;
- int *ivar;
chipset_attach(dev, device_get_unit(dev));
secondary = pci_get_secondarybus(dev);
if (secondary) {
child = device_add_child(dev, "pci", -1);
- ivar = malloc(sizeof ivar[0], M_DEVBUF /* XXX */, M_NOWAIT);
- if (ivar == NULL)
- panic("out of memory");
- device_set_ivars(child, ivar);
- ivar[0] = secondary;
+ *(int*) device_get_softc(dev) = secondary;
return bus_generic_attach(dev);
} else
return 0;
@@ -782,7 +777,7 @@ pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
{
switch (which) {
case PCIB_IVAR_BUS:
- *result = *(int*) device_get_ivars(dev);
+ *result = *(int*) device_get_softc(dev);
return 0;
}
return ENOENT;
@@ -793,7 +788,7 @@ pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
{
switch (which) {
case PCIB_IVAR_BUS:
- *(int*) device_get_ivars(dev) = value;
+ *(int*) device_get_softc(dev) = value;
return 0;
}
return ENOENT;
@@ -859,7 +854,7 @@ static device_method_t pcib_methods[] = {
static driver_t pcib_driver = {
"pcib",
pcib_methods,
- 1,
+ sizeof(int),
};
static devclass_t pcib_devclass;
OpenPOWER on IntegriCloud