Commit 2d549116 authored by Mark Brown's avatar Mark Brown

Merge branch 'spi-4.20' into spi-linus

parents 7566ec39 29bdedfd
...@@ -88,7 +88,7 @@ struct bcm2835_spi { ...@@ -88,7 +88,7 @@ struct bcm2835_spi {
u8 *rx_buf; u8 *rx_buf;
int tx_len; int tx_len;
int rx_len; int rx_len;
bool dma_pending; unsigned int dma_pending;
}; };
static inline u32 bcm2835_rd(struct bcm2835_spi *bs, unsigned reg) static inline u32 bcm2835_rd(struct bcm2835_spi *bs, unsigned reg)
...@@ -155,8 +155,7 @@ static irqreturn_t bcm2835_spi_interrupt(int irq, void *dev_id) ...@@ -155,8 +155,7 @@ static irqreturn_t bcm2835_spi_interrupt(int irq, void *dev_id)
/* Write as many bytes as possible to FIFO */ /* Write as many bytes as possible to FIFO */
bcm2835_wr_fifo(bs); bcm2835_wr_fifo(bs);
/* based on flags decide if we can finish the transfer */ if (!bs->rx_len) {
if (bcm2835_rd(bs, BCM2835_SPI_CS) & BCM2835_SPI_CS_DONE) {
/* Transfer complete - reset SPI HW */ /* Transfer complete - reset SPI HW */
bcm2835_spi_reset_hw(master); bcm2835_spi_reset_hw(master);
/* wake up the framework */ /* wake up the framework */
...@@ -233,10 +232,9 @@ static void bcm2835_spi_dma_done(void *data) ...@@ -233,10 +232,9 @@ static void bcm2835_spi_dma_done(void *data)
* is called the tx-dma must have finished - can't get to this * is called the tx-dma must have finished - can't get to this
* situation otherwise... * situation otherwise...
*/ */
dmaengine_terminate_all(master->dma_tx); if (cmpxchg(&bs->dma_pending, true, false)) {
dmaengine_terminate_all(master->dma_tx);
/* mark as no longer pending */ }
bs->dma_pending = 0;
/* and mark as completed */; /* and mark as completed */;
complete(&master->xfer_completion); complete(&master->xfer_completion);
...@@ -342,6 +340,7 @@ static int bcm2835_spi_transfer_one_dma(struct spi_master *master, ...@@ -342,6 +340,7 @@ static int bcm2835_spi_transfer_one_dma(struct spi_master *master,
if (ret) { if (ret) {
/* need to reset on errors */ /* need to reset on errors */
dmaengine_terminate_all(master->dma_tx); dmaengine_terminate_all(master->dma_tx);
bs->dma_pending = false;
bcm2835_spi_reset_hw(master); bcm2835_spi_reset_hw(master);
return ret; return ret;
} }
...@@ -617,10 +616,9 @@ static void bcm2835_spi_handle_err(struct spi_master *master, ...@@ -617,10 +616,9 @@ static void bcm2835_spi_handle_err(struct spi_master *master,
struct bcm2835_spi *bs = spi_master_get_devdata(master); struct bcm2835_spi *bs = spi_master_get_devdata(master);
/* if an error occurred and we have an active dma, then terminate */ /* if an error occurred and we have an active dma, then terminate */
if (bs->dma_pending) { if (cmpxchg(&bs->dma_pending, true, false)) {
dmaengine_terminate_all(master->dma_tx); dmaengine_terminate_all(master->dma_tx);
dmaengine_terminate_all(master->dma_rx); dmaengine_terminate_all(master->dma_rx);
bs->dma_pending = 0;
} }
/* and reset */ /* and reset */
bcm2835_spi_reset_hw(master); bcm2835_spi_reset_hw(master);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment