/* for dma spi transfers, we have to setup rx channel, otherwise there is no reliable way how to recognize that spi transfer is done dma complete callbacks are called before real spi transfer is finished and if only tx dma channel is set up (and rx fifo overflow event masked) spi master done event irq is not generated unless rx fifo is empty (emptied) so we need rx tmp buffer to use for rx dma if user does not provide one  */
static int au1550_spi_dma_rxtmp_alloc(struct au1550_spi *hw, unsigned size)
/* for dma spi transfers, we have to setup rx channel, otherwise there is no reliable way how to recognize that spi transfer is done dma complete callbacks are called before real spi transfer is finished and if only tx dma channel is set up (and rx fifo overflow event masked) spi master done event irq is not generated unless rx fifo is empty (emptied) so we need rx tmp buffer to use for rx dma if user does not provide one  */
static int au1550_spi_dma_rxtmp_alloc(struct au1550_spi *hw, unsigned size)
{
	hw->dma_rx_tmpbuf = kmalloc(size, GFP_KERNEL);
	if (!hw->dma_rx_tmpbuf)
		return -ENOMEM;
	hw->dma_rx_tmpbuf_size = size;
	hw->dma_rx_tmpbuf_addr = dma_map_single(hw->dev, hw->dma_rx_tmpbuf,
			size, DMA_FROM_DEVICE);
	if (dma_mapping_error(hw->dev, hw->dma_rx_tmpbuf_addr)) {
		kfree(hw->dma_rx_tmpbuf);
		hw->dma_rx_tmpbuf = 0;
		hw->dma_rx_tmpbuf_size = 0;
		return -EFAULT;
	}
	return 0;
}