aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/cardbus/cardbus.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/cardbus/cardbus.c')
-rw-r--r--sys/dev/cardbus/cardbus.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/sys/dev/cardbus/cardbus.c b/sys/dev/cardbus/cardbus.c
index ffa90ebb6224..e4d546799482 100644
--- a/sys/dev/cardbus/cardbus.c
+++ b/sys/dev/cardbus/cardbus.c
@@ -93,13 +93,10 @@ static int
cardbus_attach(device_t cbdev)
{
struct cardbus_softc *sc;
-#ifdef PCI_RES_BUS
int rid;
-#endif
sc = device_get_softc(cbdev);
sc->sc_dev = cbdev;
-#ifdef PCI_RES_BUS
rid = 0;
sc->sc_bus = bus_alloc_resource(cbdev, PCI_RES_BUS, &rid,
pcib_get_bus(cbdev), pcib_get_bus(cbdev), 1, 0);
@@ -107,25 +104,18 @@ cardbus_attach(device_t cbdev)
device_printf(cbdev, "failed to allocate bus number\n");
return (ENXIO);
}
-#else
- device_printf(cbdev, "Your bus numbers may be AFU\n");
-#endif
return (0);
}
static int
cardbus_detach(device_t cbdev)
{
-#ifdef PCI_RES_BUS
struct cardbus_softc *sc;
-#endif
cardbus_detach_card(cbdev);
-#ifdef PCI_RES_BUS
sc = device_get_softc(cbdev);
device_printf(cbdev, "Freeing up the allocatd bus\n");
(void)bus_release_resource(cbdev, PCI_RES_BUS, 0, sc->sc_bus);
-#endif
return (0);
}
@@ -208,7 +198,7 @@ cardbus_attach_card(device_t cbdev)
if (dinfo->pci.cfg.mfdev)
cardbusfunchigh = PCI_FUNCMAX;
- child = device_add_child(cbdev, NULL, -1);
+ child = device_add_child(cbdev, NULL, DEVICE_UNIT_ANY);
if (child == NULL) {
DEVPRINTF((cbdev, "Cannot add child!\n"));
pci_freecfg((struct pci_devinfo *)dinfo);
@@ -222,6 +212,7 @@ cardbus_attach_card(device_t cbdev)
DEVPRINTF((cbdev, "Warning: Bogus CIS ignored\n"));
pci_cfg_save(dinfo->pci.cfg.dev, &dinfo->pci, 0);
pci_cfg_restore(dinfo->pci.cfg.dev, &dinfo->pci);
+ pci_clear_pme(child);
cardbus_device_setup_regs(&dinfo->pci.cfg);
pci_add_resources(cbdev, child, 1, dinfo->mprefetchable);
pci_print_verbose(&dinfo->pci);
@@ -255,8 +246,6 @@ cardbus_detach_card(device_t cbdev)
bus_topo_lock();
err = bus_generic_detach(cbdev);
- if (err == 0)
- err = device_delete_children(cbdev);
bus_topo_unlock();
if (err)
return (err);