diff options
| author | Honghui Jiang <jiang_hh2019@163.com> | 2026-08-14 11:14:16 +0800 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2026-08-14 16:48:50 +0100 |
| commit | b82b2dfc93d3c7729250e1107b7121775f5dfd40 (patch) | |
| tree | 071f93f273489eb873c2b711758e0faf17413e0d | |
| parent | 367cea239fc93094e5c16a72724800e0358f5c46 (diff) | |
| download | linux-b82b2dfc93d3c7729250e1107b7121775f5dfd40.tar.gz linux-b82b2dfc93d3c7729250e1107b7121775f5dfd40.zip | |
spi: Move __spi_unmap_msg() before __spi_map_msg()
Move __spi_unmap_msg() above __spi_map_msg() so the mapping error path
can call it without a forward declaration. This is a code-only
relocation with no functional change.
Suggested-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Honghui Jiang <jiang_hh2019@163.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20260814031419.43378-3-jiang_hh2019@163.com
Signed-off-by: Mark Brown <broonie@kernel.org>
| -rw-r--r-- | drivers/spi/spi.c | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 0e86dc954713..bfb5ac93c8ee 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1418,7 +1418,29 @@ void spi_unmap_buf(struct spi_controller *ctlr, struct device *dev, spi_unmap_buf_attrs(ctlr, dev, sgt, dir, 0); } -static int __spi_unmap_msg(struct spi_controller *ctlr, struct spi_message *msg); +static int __spi_unmap_msg(struct spi_controller *ctlr, struct spi_message *msg) +{ + struct device *rx_dev = ctlr->cur_rx_dma_dev; + struct device *tx_dev = ctlr->cur_tx_dma_dev; + struct spi_transfer *xfer; + + list_for_each_entry(xfer, &msg->transfers, transfer_list) { + /* The sync has already been done after each transfer. */ + unsigned long attrs = DMA_ATTR_SKIP_CPU_SYNC; + + if (xfer->rx_sg_mapped) + spi_unmap_buf_attrs(ctlr, rx_dev, &xfer->rx_sg, + DMA_FROM_DEVICE, attrs); + xfer->rx_sg_mapped = false; + + if (xfer->tx_sg_mapped) + spi_unmap_buf_attrs(ctlr, tx_dev, &xfer->tx_sg, + DMA_TO_DEVICE, attrs); + xfer->tx_sg_mapped = false; + } + + return 0; +} static int __spi_map_msg(struct spi_controller *ctlr, struct spi_message *msg) { @@ -1487,30 +1509,6 @@ unwind: return ret; } -static int __spi_unmap_msg(struct spi_controller *ctlr, struct spi_message *msg) -{ - struct device *rx_dev = ctlr->cur_rx_dma_dev; - struct device *tx_dev = ctlr->cur_tx_dma_dev; - struct spi_transfer *xfer; - - list_for_each_entry(xfer, &msg->transfers, transfer_list) { - /* The sync has already been done after each transfer. */ - unsigned long attrs = DMA_ATTR_SKIP_CPU_SYNC; - - if (xfer->rx_sg_mapped) - spi_unmap_buf_attrs(ctlr, rx_dev, &xfer->rx_sg, - DMA_FROM_DEVICE, attrs); - xfer->rx_sg_mapped = false; - - if (xfer->tx_sg_mapped) - spi_unmap_buf_attrs(ctlr, tx_dev, &xfer->tx_sg, - DMA_TO_DEVICE, attrs); - xfer->tx_sg_mapped = false; - } - - return 0; -} - static void spi_dma_sync_for_device(struct spi_controller *ctlr, struct spi_transfer *xfer) { |
