summaryrefslogtreecommitdiffstats
path: root/sys/dev/cardbus/cardbus.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2010-01-05 20:42:25 +0000
committerjhb <jhb@FreeBSD.org>2010-01-05 20:42:25 +0000
commit2dd11a3eaaa7e7f9ee8766d13f00bfef1766ff90 (patch)
treede14655cb75970d20c9f5724184782b10b6a3cae /sys/dev/cardbus/cardbus.c
parenta0dce5cf22b7c2ceef7a745abd732f54a5447b7c (diff)
downloadFreeBSD-src-2dd11a3eaaa7e7f9ee8766d13f00bfef1766ff90.zip
FreeBSD-src-2dd11a3eaaa7e7f9ee8766d13f00bfef1766ff90.tar.gz
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
Diffstat (limited to 'sys/dev/cardbus/cardbus.c')
-rw-r--r--sys/dev/cardbus/cardbus.c31
1 files changed, 1 insertions, 30 deletions
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 */
/************************************************************************/
OpenPOWER on IntegriCloud