Merge branch 'spi-4.20' into spi-4.21 for bcm stuff.
authorMark Brown <broonie@kernel.org>
Wed, 28 Nov 2018 15:55:24 +0000 (15:55 +0000)
committerMark Brown <broonie@kernel.org>
Wed, 28 Nov 2018 15:55:24 +0000 (15:55 +0000)
1  2 
drivers/spi/spi-bcm2835.c

index b0b87ff936c70b1fc968814e93c001242eae51c0,774161bbcb2e90b803d9ccf2c55559b79536de55..43c6ca535800a4d18996d4ec4bd5873626b3cfcf
@@@ -155,8 -155,7 +155,7 @@@ static irqreturn_t bcm2835_spi_interrup
        /* Write as many bytes as possible to FIFO */
        bcm2835_wr_fifo(bs);
  
-       /* based on flags decide if we can finish the transfer */
-       if (bcm2835_rd(bs, BCM2835_SPI_CS) & BCM2835_SPI_CS_DONE) {
+       if (!bs->rx_len) {
                /* Transfer complete - reset SPI HW */
                bcm2835_spi_reset_hw(master);
                /* wake up the framework */
@@@ -233,10 -232,9 +232,9 @@@ static void bcm2835_spi_dma_done(void *
         * is called the tx-dma must have finished - can't get to this
         * situation otherwise...
         */
-       dmaengine_terminate_all(master->dma_tx);
-       /* mark as no longer pending */
-       bs->dma_pending = 0;
+       if (cmpxchg(&bs->dma_pending, true, false)) {
+               dmaengine_terminate_all(master->dma_tx);
+       }
  
        /* and mark as completed */;
        complete(&master->xfer_completion);
@@@ -342,6 -340,7 +340,7 @@@ static int bcm2835_spi_transfer_one_dma
        if (ret) {
                /* need to reset on errors */
                dmaengine_terminate_all(master->dma_tx);
+               bs->dma_pending = false;
                bcm2835_spi_reset_hw(master);
                return ret;
        }
@@@ -617,10 -616,9 +616,9 @@@ static void bcm2835_spi_handle_err(stru
        struct bcm2835_spi *bs = spi_master_get_devdata(master);
  
        /* 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_rx);
-               bs->dma_pending = 0;
        }
        /* and reset */
        bcm2835_spi_reset_hw(master);
@@@ -843,4 -841,4 +841,4 @@@ module_platform_driver(bcm2835_spi_driv
  
  MODULE_DESCRIPTION("SPI controller driver for Broadcom BCM2835");
  MODULE_AUTHOR("Chris Boot <bootc@bootc.net>");
 -MODULE_LICENSE("GPL v2");
 +MODULE_LICENSE("GPL");