int
ata_detach(device_t dev)
{
    struct ata_channel *ch = device_get_softc(dev);
    device_t *children;
    int nchildren, i;

    /* check that we have a valid channel to detach */
    if (!ch->r_irq)
	return ENXIO;

    /* grap the channel lock so no new requests gets launched */
    spin_lock(&ch->state_mtx);
    ch->state |= ATA_STALL_QUEUE;
    spin_unlock(&ch->state_mtx);

    /* detach & delete all children */
    if (!device_get_children(dev, &children, &nchildren)) {
	for (i = 0; i < nchildren; i++)
	    if (children[i])
		device_delete_child(dev, children[i]);
	kfree(children, M_TEMP);
    } 

    /* release resources */
    bus_teardown_intr(dev, ch->r_irq, ch->ih);
    bus_release_resource(dev, SYS_RES_IRQ, ATA_IRQ_RID, ch->r_irq);
    ch->r_irq = NULL;
    spin_uninit(&ch->state_mtx);
    spin_uninit(&ch->queue_mtx);
    return 0;
}
Beispiel #2
0
void drm_dma_takedown(struct drm_device *dev)
{
	drm_device_dma_t  *dma = dev->dma;
	int		  i, j;

	if (dma == NULL)
		return;

	/* Clear dma buffers */
	for (i = 0; i <= DRM_MAX_ORDER; i++) {
		if (dma->bufs[i].seg_count) {
			DRM_DEBUG("order %d: buf_count = %d,"
			    " seg_count = %d\n", i, dma->bufs[i].buf_count,
			    dma->bufs[i].seg_count);
			for (j = 0; j < dma->bufs[i].seg_count; j++) {
				drm_pci_free(dev, dma->bufs[i].seglist[j]);
			}
			drm_free(dma->bufs[i].seglist, M_DRM);
		}

	   	if (dma->bufs[i].buf_count) {
		   	for (j = 0; j < dma->bufs[i].buf_count; j++) {
				drm_free(dma->bufs[i].buflist[j].dev_private,
				    M_DRM);
			}
			drm_free(dma->bufs[i].buflist, M_DRM);
		}
	}

	drm_free(dma->buflist, M_DRM);
	drm_free(dma->pagelist, M_DRM);
	drm_free(dev->dma, M_DRM);
	dev->dma = NULL;
	spin_uninit(&dev->dma_lock);
}
Beispiel #3
0
void
AcpiOsDeleteLock (ACPI_SPINLOCK Spin)
{
    if (Spin == NULL)
	return;
    spin_uninit(&Spin->lock);
    kfree(Spin, M_ACPISEM);
}
Beispiel #4
0
static int
ata_usbchannel_detach(device_t dev)
{
    struct ata_channel *ch = device_get_softc(dev);
    device_t *children;
    int nchildren, i;

    /* detach & delete all children */
    if (!device_get_children(dev, &children, &nchildren)) {
        for (i = 0; i < nchildren; i++)
            if (children[i])
                device_delete_child(dev, children[i]);
        kfree(children, M_TEMP);
    }
    spin_uninit(&ch->state_mtx);
    spin_uninit(&ch->queue_mtx);
    return 0;
}
Beispiel #5
0
/*
 * Requires that the caller is the exclusive owner of this lock.
 */
void
lockuninit(struct lock *l)
{
	/*
	 * At this point we should have removed all the references to this lock
	 * so there can't be anyone waiting on it.
	 */
	KKASSERT(l->lk_waitcount == 0);

	spin_uninit(&l->lk_spinlock);
}
Beispiel #6
0
ACPI_STATUS
AcpiOsDeleteSemaphore(ACPI_HANDLE Handle)
{
#ifndef ACPI_NO_SEMAPHORES
    struct acpi_semaphore *as = (struct acpi_semaphore *)Handle;

    ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);

    ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "destroyed semaphore %p\n", as));
    spin_uninit(&as->as_spin);
    kfree(as, M_ACPISEM);
#endif /* !ACPI_NO_SEMAPHORES */

    return_ACPI_STATUS (AE_OK);
}
Beispiel #7
0
static int
atausb_detach(device_t dev)
{
    struct atausb_softc *sc = device_get_softc(dev);
    usbd_device_handle udev;
    device_t *children;
    int nchildren, i;

    /* signal that device is going away */
    sc->state = ATAUSB_S_DETACH;

    /* abort all the pipes in case there are active transfers */
    usbd_interface2device_handle(sc->iface, &udev);
    usbd_abort_pipe(udev->default_pipe);
    if (sc->bulkout_pipe)
        usbd_abort_pipe(sc->bulkout_pipe);
    if (sc->bulkin_pipe)
        usbd_abort_pipe(sc->bulkin_pipe);
    if (sc->bulkirq_pipe)
        usbd_abort_pipe(sc->bulkirq_pipe);

    /* detach & delete all children */
    if (!device_get_children(dev, &children, &nchildren)) {
        for (i = 0; i < nchildren; i++)
            device_delete_child(dev, children[i]);
        kfree(children, M_TEMP);
    }

    /* free the transfers */
    for (i = 0; i < ATAUSB_T_MAX; i++)
	if (sc->transfer[i])
	    usbd_free_xfer(sc->transfer[i]);

    /* remove all the pipes */
    if (sc->bulkout_pipe)
        usbd_close_pipe(sc->bulkout_pipe);
    if (sc->bulkin_pipe)
        usbd_close_pipe(sc->bulkin_pipe);
    if (sc->bulkirq_pipe)
        usbd_close_pipe(sc->bulkirq_pipe);

    spin_uninit(&sc->locked_mtx);
    return 0;
}
void
cv_destroy(struct cv *c)
{
	spin_uninit(&c->cv_lock);
}