/* On certain platforms, we have to allocate an interrupt as well...  */
int request_dma(unsigned int chan, const char *device_id)
/* On certain platforms, we have to allocate an interrupt as well...  */
int request_dma(unsigned int chan, const char *device_id)
{
	dma_t *dma = dma_channel(chan);
	int ret;
	if (!dma)
		goto bad_dma;
	if (xchg(&dma->lock, 1) != 0)
		goto busy;
	dma->device_id = device_id;
	dma->active    = 0;
	dma->invalid   = 1;
	ret = 0;
	if (dma->d_ops->request)
		ret = dma->d_ops->request(chan, dma);
	if (ret)
		xchg(&dma->lock, 0);
	return ret;
bad_dma:
	printk(KERN_ERR "dma: trying to allocate DMA%d\n", chan);
	return -EINVAL;
busy:
	return -EBUSY;
}