/* This clears all activities on a given DMA channel and releases it for future requests. The @regs identifier is provided by a successful call to sa1100_request_dma().  */
void sa1100_free_dma(dma_regs_t *regs)
/* This clears all activities on a given DMA channel and releases it for future requests. The @regs identifier is provided by a successful call to sa1100_request_dma().  */
void sa1100_free_dma(dma_regs_t *regs)
{
	int i;
	for (i = 0; i < SA1100_DMA_CHANNELS; i++)
		if (regs == (dma_regs_t *)&DDAR(i))
			break;
	if (i >= SA1100_DMA_CHANNELS) {
		printk(KERN_ERR "%s: bad DMA identifier\n", __func__);
		return;
	}
	if (!dma_chan[i].device) {
		printk(KERN_ERR "%s: Trying to free free DMA\n", __func__);
		return;
	}
	regs->ClrDCSR =
		(DCSR_DONEA | DCSR_DONEB | DCSR_STRTA | DCSR_STRTB |
		 DCSR_IE | DCSR_ERROR | DCSR_RUN);
	free_irq(IRQ_DMA0 + i, regs);
	dma_chan[i].device = 0;
}