No functional change, just make the code simpler and cleaner.

Signed-off-by: Feng Tang <[email protected]>
---
 drivers/spi/dw_spi_mid.c   |   33 ++++++++++-----------------------
 include/linux/spi/dw_spi.h |    5 +----
 2 files changed, 11 insertions(+), 27 deletions(-)

diff --git a/drivers/spi/dw_spi_mid.c b/drivers/spi/dw_spi_mid.c
index f7b5450..091e80b 100644
--- a/drivers/spi/dw_spi_mid.c
+++ b/drivers/spi/dw_spi_mid.c
@@ -100,13 +100,6 @@ static int mid_spi_dma_init(struct dw_spi *dws)
 
        /* Set the dma done bit to 1 */
        dws->dma_inited = 1;
-       dws->txdma_done = 1;
-       dws->rxdma_done = 1;
-
-       dws->tx_param = ((u64)(unsigned long)dws << 32)
-                               | (unsigned long)(&dws->txdma_done);
-       dws->rx_param = ((u64)(unsigned long)dws << 32)
-                               | (unsigned long)(&dws->rxdma_done);
        return 0;
 
 free_rxchan:
@@ -122,20 +115,17 @@ static void mid_spi_dma_exit(struct dw_spi *dws)
        dma_release_channel(dws->rxchan);
 }
 
+/*
+ * dws->dma_chan_done is cleared before the dma transfer starts,
+ * callback for rx/tx channel will each increment it by 1.
+ * Reaching 2 means the whole spi transaction is done.
+ */
 static void dw_spi_dma_done(void *arg)
 {
-       u64 *param = arg;
-       struct dw_spi *dws;
-       int *done;
+       struct dw_spi *dws = arg;
 
-       dws = (struct dw_spi *)(unsigned long)(*param >> 32);
-       done = (int *)(unsigned long)(*param & 0xffffffff);
-
-       *done = 1;
-       /* wait till both tx/rx channels are done */
-       if (!dws->txdma_done || !dws->rxdma_done)
+       if (++dws->dma_chan_done != 2)
                return;
-
        dw_spi_xfer_done(dws);
 }
 
@@ -159,10 +149,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int 
cs_change)
                spi_enable_chip(dws, 1);
        }
 
-       if (dws->tx_dma)
-               dws->txdma_done = 0;
-       if (dws->rx_dma)
-               dws->rxdma_done = 0;
+       dws->dma_chan_done = 0;
 
        /* 2. start the TX dma transfer */
        txchan = dws->txchan;
@@ -174,7 +161,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int 
cs_change)
                                dws->dma_addr, dws->tx_dma,
                                dws->len, flag);
                txdesc->callback = dw_spi_dma_done;
-               txdesc->callback_param = &dws->tx_param;
+               txdesc->callback_param = dws;
        }
 
        /* 3. start the RX dma transfer */
@@ -183,7 +170,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int 
cs_change)
                                dws->rx_dma, dws->dma_addr,
                                dws->len, flag);
                rxdesc->callback = dw_spi_dma_done;
-               rxdesc->callback_param = &dws->rx_param;
+               rxdesc->callback_param = dws;
        }
 
        /* rx must be started before tx due to spi instinct */
diff --git a/include/linux/spi/dw_spi.h b/include/linux/spi/dw_spi.h
index 0d20634..d9ce113 100644
--- a/include/linux/spi/dw_spi.h
+++ b/include/linux/spi/dw_spi.h
@@ -146,10 +146,7 @@ struct dw_spi {
        int                     dma_inited;
        struct dma_chan         *txchan;
        struct dma_chan         *rxchan;
-       int                     txdma_done;
-       int                     rxdma_done;
-       u64                     tx_param;
-       u64                     rx_param;
+       int                     dma_chan_done;
        struct device           *dma_dev;
        dma_addr_t              dma_addr;
        struct dw_spi_dma_ops   *dma_ops;
-- 
1.7.0.4

_______________________________________________
Meego-kernel mailing list
[email protected]
http://lists.meego.com/listinfo/meego-kernel

Reply via email to