/* On certain platforms, we have to free interrupt as well...  */
void free_dma(unsigned int chan)
/* On certain platforms, we have to free interrupt as well...  */
void free_dma(unsigned int chan)
{
	dma_t *dma = dma_channel(chan);
	if (!dma)
		goto bad_dma;
	if (dma->active) {
		printk(KERN_ERR "dma%d: freeing active DMA\n", chan);
		dma->d_ops->disable(chan, dma);
		dma->active = 0;
	}
	if (xchg(&dma->lock, 0) != 0) {
		if (dma->d_ops->free)
			dma->d_ops->free(chan, dma);
		return;
	}
	printk(KERN_ERR "dma%d: trying to free free DMA\n", chan);
	return;
bad_dma:
	printk(KERN_ERR "dma: trying to free DMA%d\n", chan);
}