]> Pileus Git - ~andy/linux/blobdiff - drivers/spi/au1550_spi.c
slob: do not pass the SLAB flags as GFP in kmem_cache_create()
[~andy/linux] / drivers / spi / au1550_spi.c
index 9149689c79d9e4ac198fefe778a9aa2de27e065e..b02f25c702fd2b2f4c54549a3332bca4da89c8ff 100644 (file)
@@ -334,7 +334,7 @@ static int au1550_spi_dma_rxtmp_alloc(struct au1550_spi *hw, unsigned size)
        hw->dma_rx_tmpbuf_size = size;
        hw->dma_rx_tmpbuf_addr = dma_map_single(hw->dev, hw->dma_rx_tmpbuf,
                        size, DMA_FROM_DEVICE);
-       if (dma_mapping_error(hw->dma_rx_tmpbuf_addr)) {
+       if (dma_mapping_error(hw->dev, hw->dma_rx_tmpbuf_addr)) {
                kfree(hw->dma_rx_tmpbuf);
                hw->dma_rx_tmpbuf = 0;
                hw->dma_rx_tmpbuf_size = 0;
@@ -369,16 +369,29 @@ static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t)
        dma_rx_addr = t->rx_dma;
 
        /*
-        * check if buffers are already dma mapped, map them otherwise
+        * check if buffers are already dma mapped, map them otherwise:
+        * - first map the TX buffer, so cache data gets written to memory
+        * - then map the RX buffer, so that cache entries (with
+        *   soon-to-be-stale data) get removed
         * use rx buffer in place of tx if tx buffer was not provided
         * use temp rx buffer (preallocated or realloc to fit) for rx dma
         */
+       if (t->tx_buf) {
+               if (t->tx_dma == 0) {   /* if DMA_ADDR_INVALID, map it */
+                       dma_tx_addr = dma_map_single(hw->dev,
+                                       (void *)t->tx_buf,
+                                       t->len, DMA_TO_DEVICE);
+                       if (dma_mapping_error(hw->dev, dma_tx_addr))
+                               dev_err(hw->dev, "tx dma map error\n");
+               }
+       }
+
        if (t->rx_buf) {
                if (t->rx_dma == 0) {   /* if DMA_ADDR_INVALID, map it */
                        dma_rx_addr = dma_map_single(hw->dev,
                                        (void *)t->rx_buf,
                                        t->len, DMA_FROM_DEVICE);
-                       if (dma_mapping_error(dma_rx_addr))
+                       if (dma_mapping_error(hw->dev, dma_rx_addr))
                                dev_err(hw->dev, "rx dma map error\n");
                }
        } else {
@@ -396,15 +409,8 @@ static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t)
                dma_sync_single_for_device(hw->dev, dma_rx_addr,
                        t->len, DMA_FROM_DEVICE);
        }
-       if (t->tx_buf) {
-               if (t->tx_dma == 0) {   /* if DMA_ADDR_INVALID, map it */
-                       dma_tx_addr = dma_map_single(hw->dev,
-                                       (void *)t->tx_buf,
-                                       t->len, DMA_TO_DEVICE);
-                       if (dma_mapping_error(dma_tx_addr))
-                               dev_err(hw->dev, "tx dma map error\n");
-               }
-       } else {
+
+       if (!t->tx_buf) {
                dma_sync_single_for_device(hw->dev, dma_rx_addr,
                                t->len, DMA_BIDIRECTIONAL);
                hw->tx = hw->rx;