Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 8cc3bad

Browse files
andy-shevbroonie
authored andcommitted
spi: Remove unneded check for orig_nents
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 <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20240507201028.564630-1-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent eab80a2 commit 8cc3bad

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

drivers/spi/spi.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,12 +1208,10 @@ static void spi_unmap_buf_attrs(struct spi_controller *ctlr,
12081208
enum dma_data_direction dir,
12091209
unsigned long attrs)
12101210
{
1211-
if (sgt->orig_nents) {
1212-
dma_unmap_sgtable(dev, sgt, dir, attrs);
1213-
sg_free_table(sgt);
1214-
sgt->orig_nents = 0;
1215-
sgt->nents = 0;
1216-
}
1211+
dma_unmap_sgtable(dev, sgt, dir, attrs);
1212+
sg_free_table(sgt);
1213+
sgt->orig_nents = 0;
1214+
sgt->nents = 0;
12171215
}
12181216

12191217
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,
13181316
if (!ctlr->cur_msg_mapped)
13191317
return;
13201318

1321-
if (xfer->tx_sg.orig_nents)
1322-
dma_sync_sgtable_for_device(tx_dev, &xfer->tx_sg, DMA_TO_DEVICE);
1323-
if (xfer->rx_sg.orig_nents)
1324-
dma_sync_sgtable_for_device(rx_dev, &xfer->rx_sg, DMA_FROM_DEVICE);
1319+
dma_sync_sgtable_for_device(tx_dev, &xfer->tx_sg, DMA_TO_DEVICE);
1320+
dma_sync_sgtable_for_device(rx_dev, &xfer->rx_sg, DMA_FROM_DEVICE);
13251321
}
13261322

13271323
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,
13331329
if (!ctlr->cur_msg_mapped)
13341330
return;
13351331

1336-
if (xfer->rx_sg.orig_nents)
1337-
dma_sync_sgtable_for_cpu(rx_dev, &xfer->rx_sg, DMA_FROM_DEVICE);
1338-
if (xfer->tx_sg.orig_nents)
1339-
dma_sync_sgtable_for_cpu(tx_dev, &xfer->tx_sg, DMA_TO_DEVICE);
1332+
dma_sync_sgtable_for_cpu(rx_dev, &xfer->rx_sg, DMA_FROM_DEVICE);
1333+
dma_sync_sgtable_for_cpu(tx_dev, &xfer->tx_sg, DMA_TO_DEVICE);
13401334
}
13411335
#else /* !CONFIG_HAS_DMA */
13421336
static inline int __spi_map_msg(struct spi_controller *ctlr,

0 commit comments

Comments
 (0)