/* Acquire a DMA channel for exclusive access, similar to clk_get().  */
int kinetis_dma_ch_get(int ch)
/* Acquire a DMA channel for exclusive access, similar to clk_get().  */
int kinetis_dma_ch_get(int ch)
{
	unsigned long fl;
	int rv;
	if (!kinetis_dma_ch_valid(ch)) {
		rv = -EINVAL;
		goto out;
	}
	spin_lock_irqsave(&dma_ch[ch].lock, fl);
	rv = dma_ch[ch].in_use ? -EBUSY : 0;
	dma_ch[ch].in_use = 1;
	spin_unlock_irqrestore(&dma_ch[ch].lock, fl);
out:
	return rv;
}