spi/rockchip: fix bug that cause the failure to read data in DMA mode
authorAddy Ke <addy.ke@rock-chips.com>
Thu, 25 Sep 2014 06:59:41 +0000 (14:59 +0800)
committerMark Brown <broonie@kernel.org>
Thu, 25 Sep 2014 13:14:44 +0000 (14:14 +0100)
In my test on RK3288-pinky board, if spi is enabled, it will begin to
read data from slave regardless of whether the DMA is ready. So we
need prepare DMA before spi is enable.

Signed-off-by: Addy Ke <addy.ke@rock-chips.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
drivers/spi/spi-rockchip.c

index c0743604b906c749b62d1fedaaa8f3250b70c0c9..1fa4eda4b432e5152870bf088fec1703349b89a5 100644 (file)
@@ -415,7 +415,7 @@ static void rockchip_spi_dma_txcb(void *data)
        spin_unlock_irqrestore(&rs->lock, flags);
 }
 
-static int rockchip_spi_dma_transfer(struct rockchip_spi *rs)
+static void rockchip_spi_prepare_dma(struct rockchip_spi *rs)
 {
        unsigned long flags;
        struct dma_slave_config rxconf, txconf;
@@ -474,8 +474,6 @@ static int rockchip_spi_dma_transfer(struct rockchip_spi *rs)
                dmaengine_submit(txdesc);
                dma_async_issue_pending(rs->dma_tx.ch);
        }
-
-       return 1;
 }
 
 static void rockchip_spi_config(struct rockchip_spi *rs)
@@ -556,16 +554,17 @@ static int rockchip_spi_transfer_one(
        else if (rs->rx)
                rs->tmode = CR0_XFM_RO;
 
-       if (master->can_dma && master->can_dma(master, spi, xfer))
+       /* we need prepare dma before spi was enabled */
+       if (master->can_dma && master->can_dma(master, spi, xfer)) {
                rs->use_dma = 1;
-       else
+               rockchip_spi_prepare_dma(rs);
+       } else {
                rs->use_dma = 0;
+       }
 
        rockchip_spi_config(rs);
 
-       if (rs->use_dma)
-               ret = rockchip_spi_dma_transfer(rs);
-       else
+       if (!rs->use_dma)
                ret = rockchip_spi_pio_transfer(rs);
 
        return ret;
This page took 0.026865 seconds and 5 git commands to generate.