* [PATCH v2 1/2] spi: use dmaengine public API instead of raw ops
@ 2026-09-30 14:02 Frank.Li
2026-09-30 14:02 ` [PATCH v2 2/2] spi: use dmaengine_get_dma_device() instead of chan->device->dev Frank.Li
0 siblings, 1 reply; 2+ messages in thread
From: Frank.Li @ 2026-09-30 14:02 UTC (permalink / raw)
To: Radu Pirea, Mark Brown, Nicolas Ferre, Alexandre Belloni,
Claudiu Beznea, Ryan Wanner,
open list:MICROCHIP AT91 USART SPI DRIVER,
moderated list:ARM/Microchip (AT91) SoC support, open list
Cc: vkoul, imx, Frank Li
From: Frank Li <Frank.Li@nxp.com>
Replace direct calls to the internal DMA device ops
device->device_issue_pending() with the proper public DMA engine wrappers:
dma_async_issue_pending().
Drivers must not call device ops directly; the wrappers provide locking,
debug checks, and a stable interface that hides internal implementation
details of the DMA controller driver.
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
Change in v2
- none
---
drivers/spi/spi-at91-usart.c | 4 ++--
drivers/spi/spi-atmel.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-at91-usart.c b/drivers/spi/spi-at91-usart.c
index 804f6194c830f..cdc771350db93 100644
--- a/drivers/spi/spi-at91-usart.c
+++ b/drivers/spi/spi-at91-usart.c
@@ -239,8 +239,8 @@ static int at91_usart_spi_dma_transfer(struct spi_controller *ctlr,
if (dma_submit_error(cookie))
goto at91_usart_spi_err_dma;
- rxchan->device->device_issue_pending(rxchan);
- txchan->device->device_issue_pending(txchan);
+ dma_async_issue_pending(rxchan);
+ dma_async_issue_pending(txchan);
return 0;
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index c8012c82c3a78..c04113ce17f70 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -877,8 +877,8 @@ static int atmel_spi_next_xfer_dma_submit(struct spi_controller *host,
cookie = txdesc->tx_submit(txdesc);
if (dma_submit_error(cookie))
goto err_dma;
- rxchan->device->device_issue_pending(rxchan);
- txchan->device->device_issue_pending(txchan);
+ dma_async_issue_pending(rxchan);
+ dma_async_issue_pending(txchan);
return 0;
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH v2 2/2] spi: use dmaengine_get_dma_device() instead of chan->device->dev
2026-09-30 14:02 [PATCH v2 1/2] spi: use dmaengine public API instead of raw ops Frank.Li
@ 2026-09-30 14:02 ` Frank.Li
0 siblings, 0 replies; 2+ messages in thread
From: Frank.Li @ 2026-09-30 14:02 UTC (permalink / raw)
To: Mark Brown, Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Vladimir Oltean, Frank Li,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Han Xu,
Haibo Chen, Linus Walleij, open list:SPI SUBSYSTEM,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
open list, open list:FREESCALE DSPI DRIVER
Cc: vkoul, imx
From: Frank Li <Frank.Li@nxp.com>
Replace direct dma_chan::device::dev access with the proper
dmaengine_get_dma_device() for consumer API
chan->device->dev is not always the device used for DMA mapping. Some DMA
engines support per-channel IOMMU mappings, so different channels may use
different DMA devices. dmaengine_get_dma_device() returns the correct
device for each channel.
This also prepares for making the DMA engine provider data structures
private. DMA consumers should not access DMA engine internals directly.
Assisted-by: LLM
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
Change in v2
- move dmaengine_get_dma_device() after check dma_chan available. (Mark brown)
Check all unders driver/spi/ by rename device to _device in dma_chan struct
with all yes config.
Still few left, one for copy_align access, which need new API. some filter
DMA channel, need new API to get provider devices.
In https://lore.kernel.org/imx/67966b47-22cb-4b07-80c7-2044f557dbcb@app.fastmail.com/
There are better idea to move map singe/sg into dma prep functions.
But it takes more times, not straightforward works. Let replace this firstly,
---
drivers/spi/spi-bcm2835.c | 25 ++++++++++++----------
drivers/spi/spi-cadence-quadspi.c | 2 +-
drivers/spi/spi-ep93xx.c | 8 ++++---
drivers/spi/spi-fsl-dspi.c | 35 ++++++++++++++++++-------------
drivers/spi/spi-imx.c | 10 ++++-----
drivers/spi/spi-nxp-xspi.c | 16 +++++++-------
drivers/spi/spi-pl022.c | 19 ++++++++++-------
drivers/spi/spi-sh-msiof.c | 12 +++++------
8 files changed, 69 insertions(+), 58 deletions(-)
diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
index 8f8715809c7ce..884941f2e9b9a 100644
--- a/drivers/spi/spi-bcm2835.c
+++ b/drivers/spi/spi-bcm2835.c
@@ -527,7 +527,7 @@ static void bcm2835_spi_transfer_prologue(struct spi_controller *ctlr,
| BCM2835_SPI_CS_CLEAR_TX
| BCM2835_SPI_CS_DONE);
- dma_sync_single_for_device(ctlr->dma_rx->device->dev,
+ dma_sync_single_for_device(dmaengine_get_dma_device(ctlr->dma_rx),
sg_dma_address(&tfr->rx_sg.sgl[0]),
bs->rx_prologue, DMA_FROM_DEVICE);
@@ -871,7 +871,7 @@ static void bcm2835_dma_release(struct spi_controller *ctlr,
dmaengine_desc_free(bs->fill_tx_desc);
if (bs->fill_tx_addr)
- dma_unmap_page_attrs(ctlr->dma_tx->device->dev,
+ dma_unmap_page_attrs(dmaengine_get_dma_device(ctlr->dma_tx),
bs->fill_tx_addr, sizeof(u32),
DMA_TO_DEVICE,
DMA_ATTR_SKIP_CPU_SYNC);
@@ -891,6 +891,7 @@ static int bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev,
struct bcm2835_spi *bs)
{
struct dma_slave_config slave_config;
+ struct device *tx_dma_dev;
const __be32 *addr;
dma_addr_t dma_reg_base;
int ret;
@@ -932,11 +933,13 @@ static int bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev,
if (ret)
goto err_config;
- bs->fill_tx_addr = dma_map_page_attrs(ctlr->dma_tx->device->dev,
+ tx_dma_dev = dmaengine_get_dma_device(ctlr->dma_tx);
+
+ bs->fill_tx_addr = dma_map_page_attrs(tx_dma_dev,
ZERO_PAGE(0), 0, sizeof(u32),
DMA_TO_DEVICE,
DMA_ATTR_SKIP_CPU_SYNC);
- if (dma_mapping_error(ctlr->dma_tx->device->dev, bs->fill_tx_addr)) {
+ if (dma_mapping_error(tx_dma_dev, bs->fill_tx_addr)) {
dev_err(dev, "cannot map zero page - not using DMA mode\n");
bs->fill_tx_addr = 0;
ret = -ENOMEM;
@@ -1157,7 +1160,7 @@ static void bcm2835_spi_cleanup(struct spi_device *spi)
dmaengine_desc_free(target->clear_rx_desc);
if (target->clear_rx_addr)
- dma_unmap_single(ctlr->dma_rx->device->dev,
+ dma_unmap_single(dmaengine_get_dma_device(ctlr->dma_rx),
target->clear_rx_addr,
sizeof(u32),
DMA_TO_DEVICE);
@@ -1174,16 +1177,16 @@ static int bcm2835_spi_setup_dma(struct spi_controller *ctlr,
struct bcm2835_spi *bs,
struct bcm2835_spidev *target)
{
+ struct device *rx_dev;
int ret;
if (!ctlr->dma_rx)
return 0;
- target->clear_rx_addr = dma_map_single(ctlr->dma_rx->device->dev,
- &target->clear_rx_cs,
- sizeof(u32),
- DMA_TO_DEVICE);
- if (dma_mapping_error(ctlr->dma_rx->device->dev, target->clear_rx_addr)) {
+ rx_dev = dmaengine_get_dma_device(ctlr->dma_rx);
+ target->clear_rx_addr = dma_map_single(rx_dev, &target->clear_rx_cs,
+ sizeof(u32), DMA_TO_DEVICE);
+ if (dma_mapping_error(rx_dev, target->clear_rx_addr)) {
dev_err(&spi->dev, "cannot map clear_rx_cs\n");
target->clear_rx_addr = 0;
return -ENOMEM;
@@ -1268,7 +1271,7 @@ static int bcm2835_spi_setup(struct spi_device *spi)
target->clear_rx_cs = cs | BCM2835_SPI_CS_TA |
BCM2835_SPI_CS_DMAEN |
BCM2835_SPI_CS_CLEAR_RX;
- dma_sync_single_for_device(ctlr->dma_rx->device->dev,
+ dma_sync_single_for_device(dmaengine_get_dma_device(ctlr->dma_rx),
target->clear_rx_addr,
sizeof(u32),
DMA_TO_DEVICE);
diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index ecb0be3946965..fe5b094f0b6b3 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -1382,7 +1382,7 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata,
return 0;
}
- ddev = cqspi->rx_chan->device->dev;
+ ddev = dmaengine_get_dma_device(cqspi->rx_chan);
dma_dst = dma_map_single(ddev, buf, len, DMA_FROM_DEVICE);
if (dma_mapping_error(ddev, dma_dst)) {
dev_err(dev, "dma mapping failed\n");
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index bf389d7590d35..d8f4aa38685f5 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -273,6 +273,7 @@ ep93xx_spi_dma_prepare(struct spi_controller *host,
struct dma_async_tx_descriptor *txd;
enum dma_slave_buswidth buswidth;
struct dma_slave_config conf;
+ struct device *dma_dev;
struct scatterlist *sg;
struct sg_table *sgt;
struct dma_chan *chan;
@@ -348,14 +349,15 @@ ep93xx_spi_dma_prepare(struct spi_controller *host,
return ERR_PTR(-EINVAL);
}
- nents = dma_map_sg(chan->device->dev, sgt->sgl, sgt->nents, dir);
+ dma_dev = dmaengine_get_dma_device(chan);
+ nents = dma_map_sg(dma_dev, sgt->sgl, sgt->nents, dir);
if (!nents)
return ERR_PTR(-ENOMEM);
txd = dmaengine_prep_slave_sg(chan, sgt->sgl, nents, conf.direction,
DMA_CTRL_ACK);
if (!txd) {
- dma_unmap_sg(chan->device->dev, sgt->sgl, sgt->nents, dir);
+ dma_unmap_sg(dma_dev, sgt->sgl, sgt->nents, dir);
return ERR_PTR(-ENOMEM);
}
return txd;
@@ -384,7 +386,7 @@ static void ep93xx_spi_dma_finish(struct spi_controller *host,
sgt = &espi->tx_sgt;
}
- dma_unmap_sg(chan->device->dev, sgt->sgl, sgt->nents, dir);
+ dma_unmap_sg(dmaengine_get_dma_device(chan), sgt->sgl, sgt->nents, dir);
}
static void ep93xx_spi_dma_callback(void *callback_param)
diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 23e6bc5f202e2..f03488870d024 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -670,6 +670,7 @@ static void dspi_dma_xfer(struct fsl_dspi *dspi)
static int dspi_request_dma(struct fsl_dspi *dspi, phys_addr_t phy_addr)
{
struct device *dev = &dspi->pdev->dev;
+ struct device *tx_dev, *rx_dev;
struct dma_slave_config cfg;
struct fsl_dspi_dma *dma;
int ret;
@@ -688,20 +689,23 @@ static int dspi_request_dma(struct fsl_dspi *dspi, phys_addr_t phy_addr)
goto err_tx_channel;
}
+ tx_dev = dmaengine_get_dma_device(dma->chan_tx);
+ rx_dev = dmaengine_get_dma_device(dma->chan_rx);
+
if (spi_controller_is_target(dspi->ctlr)) {
/*
* In target mode we have to be ready to receive the maximum
* that can possibly be transferred at once by EDMA without any
* FIFO underflows.
*/
- dma->bufsize = min(dma_get_max_seg_size(dma->chan_rx->device->dev),
- dma_get_max_seg_size(dma->chan_tx->device->dev)) *
+ dma->bufsize = min(dma_get_max_seg_size(rx_dev),
+ dma_get_max_seg_size(tx_dev)) *
DMA_SLAVE_BUSWIDTH_4_BYTES;
} else {
dma->bufsize = PAGE_SIZE;
}
- dma->tx_dma_buf = dma_alloc_noncoherent(dma->chan_tx->device->dev,
+ dma->tx_dma_buf = dma_alloc_noncoherent(tx_dev,
dma->bufsize, &dma->tx_dma_phys,
DMA_TO_DEVICE, GFP_KERNEL);
if (!dma->tx_dma_buf) {
@@ -709,7 +713,7 @@ static int dspi_request_dma(struct fsl_dspi *dspi, phys_addr_t phy_addr)
goto err_tx_dma_buf;
}
- dma->rx_dma_buf = dma_alloc_noncoherent(dma->chan_rx->device->dev,
+ dma->rx_dma_buf = dma_alloc_noncoherent(rx_dev,
dma->bufsize, &dma->rx_dma_phys,
DMA_FROM_DEVICE, GFP_KERNEL);
if (!dma->rx_dma_buf) {
@@ -746,12 +750,11 @@ static int dspi_request_dma(struct fsl_dspi *dspi, phys_addr_t phy_addr)
return 0;
err_slave_config:
- dma_free_noncoherent(dma->chan_rx->device->dev, dma->bufsize,
- dma->rx_dma_buf, dma->rx_dma_phys,
- DMA_FROM_DEVICE);
+ dma_free_noncoherent(rx_dev, dma->bufsize, dma->rx_dma_buf,
+ dma->rx_dma_phys, DMA_FROM_DEVICE);
err_rx_dma_buf:
- dma_free_noncoherent(dma->chan_tx->device->dev, dma->bufsize,
- dma->tx_dma_buf, dma->tx_dma_phys, DMA_TO_DEVICE);
+ dma_free_noncoherent(tx_dev, dma->bufsize, dma->tx_dma_buf,
+ dma->tx_dma_phys, DMA_TO_DEVICE);
err_tx_dma_buf:
dma_release_channel(dma->chan_tx);
err_tx_channel:
@@ -771,16 +774,18 @@ static void dspi_release_dma(struct fsl_dspi *dspi)
return;
if (dma->chan_tx) {
- dma_free_noncoherent(dma->chan_tx->device->dev, dma->bufsize,
- dma->tx_dma_buf, dma->tx_dma_phys,
- DMA_TO_DEVICE);
+ struct device *tx_dev = dmaengine_get_dma_device(dma->chan_tx);
+
+ dma_free_noncoherent(tx_dev, dma->bufsize, dma->tx_dma_buf,
+ dma->tx_dma_phys, DMA_TO_DEVICE);
dma_release_channel(dma->chan_tx);
}
if (dma->chan_rx) {
- dma_free_noncoherent(dma->chan_rx->device->dev, dma->bufsize,
- dma->rx_dma_buf, dma->rx_dma_phys,
- DMA_FROM_DEVICE);
+ struct device *rx_dev = dmaengine_get_dma_device(dma->chan_rx);
+
+ dma_free_noncoherent(rx_dev, dma->bufsize, dma->rx_dma_buf,
+ dma->rx_dma_phys, DMA_FROM_DEVICE);
dma_release_channel(dma->chan_rx);
}
}
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 6f9686df0486e..868f963e61371 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -1467,8 +1467,8 @@ static int spi_imx_calculate_timeout(struct spi_imx_data *spi_imx, int size)
static void spi_imx_dma_unmap(struct spi_imx_data *spi_imx,
struct dma_data_package *dma_data)
{
- struct device *tx_dev = spi_imx->controller->dma_tx->device->dev;
- struct device *rx_dev = spi_imx->controller->dma_rx->device->dev;
+ struct device *tx_dev = dmaengine_get_dma_device(spi_imx->controller->dma_tx);
+ struct device *rx_dev = dmaengine_get_dma_device(spi_imx->controller->dma_rx);
dma_unmap_single(tx_dev, dma_data->dma_tx_addr,
DMA_CACHE_ALIGNED_LEN(dma_data->dma_len),
@@ -1526,8 +1526,8 @@ static int spi_imx_dma_map(struct spi_imx_data *spi_imx,
struct dma_data_package *dma_data)
{
struct spi_controller *controller = spi_imx->controller;
- struct device *tx_dev = controller->dma_tx->device->dev;
- struct device *rx_dev = controller->dma_rx->device->dev;
+ struct device *tx_dev = dmaengine_get_dma_device(controller->dma_tx);
+ struct device *rx_dev = dmaengine_get_dma_device(controller->dma_rx);
int ret;
dma_data->dma_tx_addr = dma_map_single(tx_dev, dma_data->dma_tx_buf,
@@ -1919,7 +1919,7 @@ static int spi_imx_dma_package_transfer(struct spi_imx_data *spi_imx,
return ret;
/* Trim the DMA RX buffer and copy the actual data to rx_buf */
- dma_sync_single_for_cpu(controller->dma_rx->device->dev, dma_data->dma_rx_addr,
+ dma_sync_single_for_cpu(dmaengine_get_dma_device(controller->dma_rx), dma_data->dma_rx_addr,
dma_data->dma_len, DMA_FROM_DEVICE);
spi_imx_dma_rx_data_handle(spi_imx, dma_data, transfer->rx_buf + spi_imx->rx_offset,
word_delay);
diff --git a/drivers/spi/spi-nxp-xspi.c b/drivers/spi/spi-nxp-xspi.c
index 70cbc3ef658b6..38c8d6269aadd 100644
--- a/drivers/spi/spi-nxp-xspi.c
+++ b/drivers/spi/spi-nxp-xspi.c
@@ -841,23 +841,23 @@ static int nxp_xspi_ahb_dma_read(struct nxp_xspi *xspi,
{
struct dma_async_tx_descriptor *desc;
struct dma_chan *chan = xspi->dma_rx;
+ struct device *dma_dev = dmaengine_get_dma_device(chan);
unsigned long timeout;
dma_addr_t src_addr, dst_addr;
int ret = 0;
- dst_addr = dma_map_single(chan->device->dev,
- op->data.buf.in, op->data.nbytes,
+ dst_addr = dma_map_single(dma_dev, op->data.buf.in, op->data.nbytes,
DMA_FROM_DEVICE);
- if (dma_mapping_error(chan->device->dev, dst_addr)) {
+ if (dma_mapping_error(dma_dev, dst_addr)) {
dev_err(xspi->dev, "failed to map DMA dst buffer\n");
return -ENOMEM;
}
- src_addr = dma_map_resource(chan->device->dev,
+ src_addr = dma_map_resource(dma_dev,
(phys_addr_t)xspi->memmap_phy + op->addr.val,
op->data.nbytes,
DMA_TO_DEVICE, 0);
- if (dma_mapping_error(chan->device->dev, src_addr)) {
+ if (dma_mapping_error(dma_dev, src_addr)) {
dev_err(xspi->dev, "failed to map DMA src resource\n");
ret = -ENOMEM;
goto err_unmap_dst;
@@ -886,12 +886,10 @@ static int nxp_xspi_ahb_dma_read(struct nxp_xspi *xspi,
}
err_unmap_src:
- dma_unmap_resource(chan->device->dev, src_addr,
- op->data.nbytes, DMA_TO_DEVICE, 0);
+ dma_unmap_resource(dma_dev, src_addr, op->data.nbytes, DMA_TO_DEVICE, 0);
err_unmap_dst:
- dma_unmap_single(chan->device->dev, dst_addr,
- op->data.nbytes, DMA_FROM_DEVICE);
+ dma_unmap_single(dma_dev, dst_addr, op->data.nbytes, DMA_FROM_DEVICE);
return ret;
}
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 4877ab909c51b..3ff30486b2892 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -684,9 +684,9 @@ static void readwriter(struct pl022 *pl022)
static void unmap_free_dma_scatter(struct pl022 *pl022)
{
/* Unmap and free the SG tables */
- dma_unmap_sg(pl022->dma_tx_channel->device->dev, pl022->sgt_tx.sgl,
+ dma_unmap_sg(dmaengine_get_dma_device(pl022->dma_tx_channel), pl022->sgt_tx.sgl,
pl022->sgt_tx.nents, DMA_TO_DEVICE);
- dma_unmap_sg(pl022->dma_rx_channel->device->dev, pl022->sgt_rx.sgl,
+ dma_unmap_sg(dmaengine_get_dma_device(pl022->dma_rx_channel), pl022->sgt_rx.sgl,
pl022->sgt_rx.nents, DMA_FROM_DEVICE);
sg_free_table(&pl022->sgt_rx);
sg_free_table(&pl022->sgt_tx);
@@ -811,6 +811,7 @@ static int configure_dma(struct pl022 *pl022)
struct dma_chan *txchan = pl022->dma_tx_channel;
struct dma_async_tx_descriptor *rxdesc;
struct dma_async_tx_descriptor *txdesc;
+ struct device *rx_dev, *tx_dev;
/* Check that the channels are available */
if (!rxchan || !txchan)
@@ -924,14 +925,16 @@ static int configure_dma(struct pl022 *pl022)
setup_dma_scatter(pl022, pl022->tx,
pl022->cur_transfer->len, &pl022->sgt_tx);
+ rx_dev = dmaengine_get_dma_device(rxchan);
/* Map DMA buffers */
- rx_sglen = dma_map_sg(rxchan->device->dev, pl022->sgt_rx.sgl,
- pl022->sgt_rx.nents, DMA_FROM_DEVICE);
+ rx_sglen = dma_map_sg(rx_dev, pl022->sgt_rx.sgl,
+ pl022->sgt_rx.nents, DMA_FROM_DEVICE);
if (!rx_sglen)
goto err_rx_sgmap;
- tx_sglen = dma_map_sg(txchan->device->dev, pl022->sgt_tx.sgl,
- pl022->sgt_tx.nents, DMA_TO_DEVICE);
+ tx_dev = dmaengine_get_dma_device(txchan);
+ tx_sglen = dma_map_sg(tx_dev, pl022->sgt_tx.sgl,
+ pl022->sgt_tx.nents, DMA_TO_DEVICE);
if (!tx_sglen)
goto err_tx_sgmap;
@@ -969,10 +972,10 @@ static int configure_dma(struct pl022 *pl022)
dmaengine_terminate_all(txchan);
err_rxdesc:
dmaengine_terminate_all(rxchan);
- dma_unmap_sg(txchan->device->dev, pl022->sgt_tx.sgl,
+ dma_unmap_sg(tx_dev, pl022->sgt_tx.sgl,
pl022->sgt_tx.nents, DMA_TO_DEVICE);
err_tx_sgmap:
- dma_unmap_sg(rxchan->device->dev, pl022->sgt_rx.sgl,
+ dma_unmap_sg(rx_dev, pl022->sgt_rx.sgl,
pl022->sgt_rx.nents, DMA_FROM_DEVICE);
err_rx_sgmap:
sg_free_table(&pl022->sgt_tx);
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 90a671e9de70e..89fbdde46cfe9 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -674,7 +674,7 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx,
if (tx) {
ier_bits |= SIIER_TDREQE | SIIER_TDMAE;
- dma_sync_single_for_device(p->ctlr->dma_tx->device->dev,
+ dma_sync_single_for_device(dmaengine_get_dma_device(p->ctlr->dma_tx),
p->tx_dma_addr, len, DMA_TO_DEVICE);
desc_tx = dmaengine_prep_slave_single(p->ctlr->dma_tx,
p->tx_dma_addr, len, DMA_MEM_TO_DEV,
@@ -754,7 +754,7 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx,
}
if (rx)
- dma_sync_single_for_cpu(p->ctlr->dma_rx->device->dev,
+ dma_sync_single_for_cpu(dmaengine_get_dma_device(p->ctlr->dma_rx),
p->rx_dma_addr, len, DMA_FROM_DEVICE);
return 0;
@@ -1142,13 +1142,13 @@ static int sh_msiof_request_dma(struct sh_msiof_spi_priv *p)
if (!p->rx_dma_page)
goto free_tx_page;
- tx_dev = ctlr->dma_tx->device->dev;
+ tx_dev = dmaengine_get_dma_device(ctlr->dma_tx);
p->tx_dma_addr = dma_map_single(tx_dev, p->tx_dma_page, PAGE_SIZE,
DMA_TO_DEVICE);
if (dma_mapping_error(tx_dev, p->tx_dma_addr))
goto free_rx_page;
- rx_dev = ctlr->dma_rx->device->dev;
+ rx_dev = dmaengine_get_dma_device(ctlr->dma_rx);
p->rx_dma_addr = dma_map_single(rx_dev, p->rx_dma_page, PAGE_SIZE,
DMA_FROM_DEVICE);
if (dma_mapping_error(rx_dev, p->rx_dma_addr))
@@ -1178,9 +1178,9 @@ static void sh_msiof_release_dma(struct sh_msiof_spi_priv *p)
if (!ctlr->dma_tx)
return;
- dma_unmap_single(ctlr->dma_rx->device->dev, p->rx_dma_addr, PAGE_SIZE,
+ dma_unmap_single(dmaengine_get_dma_device(ctlr->dma_rx), p->rx_dma_addr, PAGE_SIZE,
DMA_FROM_DEVICE);
- dma_unmap_single(ctlr->dma_tx->device->dev, p->tx_dma_addr, PAGE_SIZE,
+ dma_unmap_single(dmaengine_get_dma_device(ctlr->dma_tx), p->tx_dma_addr, PAGE_SIZE,
DMA_TO_DEVICE);
free_page((unsigned long)p->rx_dma_page);
free_page((unsigned long)p->tx_dma_page);
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-30 14:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-30 14:02 [PATCH v2 1/2] spi: use dmaengine public API instead of raw ops Frank.Li
2026-09-30 14:02 ` [PATCH v2 2/2] spi: use dmaengine_get_dma_device() instead of chan->device->dev Frank.Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®