aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFeng Tang <feng.tang@intel.com>2010-12-09 10:37:35 +0000
committerAlan Cox <alan@linux.intel.com>2010-12-09 10:37:35 +0000
commit7adc11f755a0220dfb7824f0966fa0598badbbf9 (patch)
treea44a18dd2d8ec61f131d83b47fa4c2b712dfa339
parent72dd7776dc9268c5e1095440f8b608a080c1fdf6 (diff)
downloadmrst-s0i3-test-7adc11f755a0220dfb7824f0966fa0598badbbf9.tar.gz
mrst-s0i3-test-7adc11f755a0220dfb7824f0966fa0598badbbf9.tar.xz
mrst-s0i3-test-7adc11f755a0220dfb7824f0966fa0598badbbf9.zip
No functional change, just make the code simpler and cleaner.
Signed-off-by: Feng Tang <feng.tang@intel.com>
-rw-r--r--drivers/spi/dw_spi_mid.c33
-rw-r--r--include/linux/spi/dw_spi.h5
2 files changed, 11 insertions, 27 deletions
diff --git a/drivers/spi/dw_spi_mid.c b/drivers/spi/dw_spi_mid.c
index 465e1cd4142..b53ab22f3cc 100644
--- a/drivers/spi/dw_spi_mid.c
+++ b/drivers/spi/dw_spi_mid.c
@@ -103,13 +103,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:
@@ -125,20 +118,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);
}
@@ -162,10 +152,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;
@@ -177,7 +164,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 */
@@ -186,7 +173,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 b2ecf9f1f97..890266a6365 100644
--- a/include/linux/spi/dw_spi.h
+++ b/include/linux/spi/dw_spi.h
@@ -145,10 +145,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;