From 2dd11a3eaaa7e7f9ee8766d13f00bfef1766ff90 Mon Sep 17 00:00:00 2001 From: jhb Date: Tue, 5 Jan 2010 20:42:25 +0000 Subject: Move the PCI-specific logic of removing a cardbus device into a pci_delete_child() function called by the cardbus driver. The new function uses resource_list_unreserve() to release the BARs decoded by the device being removed. Reviewed by: imp Tested by: brooks --- sys/dev/cardbus/cardbus.c | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) (limited to 'sys/dev/cardbus/cardbus.c') diff --git a/sys/dev/cardbus/cardbus.c b/sys/dev/cardbus/cardbus.c index 8a333ad..6edf183 100644 --- a/sys/dev/cardbus/cardbus.c +++ b/sys/dev/cardbus/cardbus.c @@ -80,8 +80,6 @@ static void cardbus_driver_added(device_t cbdev, driver_t *driver); static int cardbus_probe(device_t cbdev); static int cardbus_read_ivar(device_t cbdev, device_t child, int which, uintptr_t *result); -static void cardbus_release_all_resources(device_t cbdev, - struct cardbus_devinfo *dinfo); /************************************************************************/ /* Probe/Attach */ @@ -226,16 +224,11 @@ cardbus_detach_card(device_t cbdev) for (tmp = 0; tmp < numdevs; tmp++) { struct cardbus_devinfo *dinfo = device_get_ivars(devlist[tmp]); - int status = device_get_state(devlist[tmp]); if (dinfo->pci.cfg.dev != devlist[tmp]) device_printf(cbdev, "devinfo dev mismatch\n"); - if (status == DS_ATTACHED || status == DS_BUSY) - device_detach(devlist[tmp]); - cardbus_release_all_resources(cbdev, dinfo); cardbus_device_destroy(dinfo); - device_delete_child(cbdev, devlist[tmp]); - pci_freecfg((struct pci_devinfo *)dinfo); + pci_delete_child(cbdev, devlist[tmp]); } POWER_DISABLE_SOCKET(device_get_parent(cbdev), cbdev); free(devlist, M_TEMP); @@ -283,28 +276,6 @@ cardbus_driver_added(device_t cbdev, driver_t *driver) free(devlist, M_TEMP); } -static void -cardbus_release_all_resources(device_t cbdev, struct cardbus_devinfo *dinfo) -{ - struct resource_list_entry *rle; - device_t dev; - - /* Turn off access to resources we're about to free */ - dev = dinfo->pci.cfg.dev; - pci_write_config(dev, PCIR_COMMAND, - pci_read_config(dev, PCIR_COMMAND, 2) & - ~(PCIM_CMD_MEMEN | PCIM_CMD_PORTEN), 2); - /* Free all allocated resources */ - STAILQ_FOREACH(rle, &dinfo->pci.resources, link) { - if (rle->res) { - BUS_RELEASE_RESOURCE(device_get_parent(cbdev), - cbdev, rle->type, rle->rid, rle->res); - rle->res = NULL; - } - } - resource_list_free(&dinfo->pci.resources); -} - /************************************************************************/ /* Other Bus Methods */ /************************************************************************/ -- cgit v1.1