]> Git Repo - J-linux.git/commitdiff
spi: Remove unneded check for orig_nents
authorAndy Shevchenko <[email protected]>
Tue, 7 May 2024 20:10:27 +0000 (23:10 +0300)
committerMark Brown <[email protected]>
Wed, 8 May 2024 02:39:46 +0000 (11:39 +0900)
Both dma_unmap_sgtable() and sg_free_table() in spi_unmap_buf_attrs()
have checks for orig_nents against 0. No need to duplicate this.
All the same applies to other DMA mapping API calls.

Also note, there is no other user in the kernel that does this kind of
checks.

Signed-off-by: Andy Shevchenko <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
drivers/spi/spi.c

index a500a4137a786cde53ae7e69cf35dfbbc8fa2424..a8966caed84142bef669ad5aa57e489f49346cb7 100644 (file)
@@ -1208,12 +1208,10 @@ static void spi_unmap_buf_attrs(struct spi_controller *ctlr,
                                enum dma_data_direction dir,
                                unsigned long attrs)
 {
-       if (sgt->orig_nents) {
-               dma_unmap_sgtable(dev, sgt, dir, attrs);
-               sg_free_table(sgt);
-               sgt->orig_nents = 0;
-               sgt->nents = 0;
-       }
+       dma_unmap_sgtable(dev, sgt, dir, attrs);
+       sg_free_table(sgt);
+       sgt->orig_nents = 0;
+       sgt->nents = 0;
 }
 
 void spi_unmap_buf(struct spi_controller *ctlr, struct device *dev,
@@ -1318,10 +1316,8 @@ static void spi_dma_sync_for_device(struct spi_controller *ctlr,
        if (!ctlr->cur_msg_mapped)
                return;
 
-       if (xfer->tx_sg.orig_nents)
-               dma_sync_sgtable_for_device(tx_dev, &xfer->tx_sg, DMA_TO_DEVICE);
-       if (xfer->rx_sg.orig_nents)
-               dma_sync_sgtable_for_device(rx_dev, &xfer->rx_sg, DMA_FROM_DEVICE);
+       dma_sync_sgtable_for_device(tx_dev, &xfer->tx_sg, DMA_TO_DEVICE);
+       dma_sync_sgtable_for_device(rx_dev, &xfer->rx_sg, DMA_FROM_DEVICE);
 }
 
 static void spi_dma_sync_for_cpu(struct spi_controller *ctlr,
@@ -1333,10 +1329,8 @@ static void spi_dma_sync_for_cpu(struct spi_controller *ctlr,
        if (!ctlr->cur_msg_mapped)
                return;
 
-       if (xfer->rx_sg.orig_nents)
-               dma_sync_sgtable_for_cpu(rx_dev, &xfer->rx_sg, DMA_FROM_DEVICE);
-       if (xfer->tx_sg.orig_nents)
-               dma_sync_sgtable_for_cpu(tx_dev, &xfer->tx_sg, DMA_TO_DEVICE);
+       dma_sync_sgtable_for_cpu(rx_dev, &xfer->rx_sg, DMA_FROM_DEVICE);
+       dma_sync_sgtable_for_cpu(tx_dev, &xfer->tx_sg, DMA_TO_DEVICE);
 }
 #else /* !CONFIG_HAS_DMA */
 static inline int __spi_map_msg(struct spi_controller *ctlr,
This page took 0.06042 seconds and 4 git commands to generate.