/* This function immediately shuts down a DMA channel's hardware, aborting any I/O that may be in progress, potentially leaving I/O hardware in an undefined state. It is unwise to call this function if there is ANY chance the hardware is still processing a command.  */
static int mxs_dma_disable(int channel)
/* This function immediately shuts down a DMA channel's hardware, aborting any I/O that may be in progress, potentially leaving I/O hardware in an undefined state. It is unwise to call this function if there is ANY chance the hardware is still processing a command.  */
static int mxs_dma_disable(int channel)
{
	struct mxs_dma_chan *pchan;
	struct mxs_apbh_regs *apbh_regs =
		(struct mxs_apbh_regs *)MXS_APBH_BASE;
	int ret;
	ret = mxs_dma_validate_chan(channel);
	if (ret)
		return ret;
	pchan = mxs_dma_channels + channel;
	if (!(pchan->flags & MXS_DMA_FLAGS_BUSY))
		return -EINVAL;
	writel(1 << (channel + APBH_CTRL0_CLKGATE_CHANNEL_OFFSET),
		&apbh_regs->hw_apbh_ctrl0_set);
	pchan->flags &= ~MXS_DMA_FLAGS_BUSY;
	pchan->active_num = 0;
	pchan->pending_num = 0;
	list_splice_init(&pchan->active, &pchan->done);
	return 0;
}