From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Niravkumar L Rabara <niravkumarlaxmidas.rabara@altera.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
Miquel Raynal <miquel.raynal@bootlin.com>
Subject: [PATCH v2 3/3] mtd: rawnand: cadence: Switch to dmaengine_get_dma_device()
Date: Tue, 24 Nov 2026 10:24:24 +0100 [thread overview]
Message-ID: <20261124-perso-upstreaming-rawnand-fixes-v2-3-69db17ad07bd@bootlin.com> (raw)
In-Reply-To: <20261124-perso-upstreaming-rawnand-fixes-v2-0-69db17ad07bd@bootlin.com>
Use the dmaengine consumer accessor instead of open-coding it (as
already done in the remove path). Do it as well for the buffer mapping
done in cadence_nand_slave_dma_transfer() so that both ends of the
transfer are mapped against the same device, which matters for DMA
engines exposing a per-channel DMA device.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
drivers/mtd/nand/raw/cadence-nand-controller.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/mtd/nand/raw/cadence-nand-controller.c b/drivers/mtd/nand/raw/cadence-nand-controller.c
index 912148f90ece..6f990469b8e5 100644
--- a/drivers/mtd/nand/raw/cadence-nand-controller.c
+++ b/drivers/mtd/nand/raw/cadence-nand-controller.c
@@ -1873,16 +1873,16 @@ static int cadence_nand_slave_dma_transfer(struct cdns_nand_ctrl *cdns_ctrl,
{
DECLARE_COMPLETION_ONSTACK(finished);
struct dma_chan *chan;
- struct dma_device *dma_dev;
dma_addr_t src_dma, dst_dma, buf_dma;
struct dma_async_tx_descriptor *tx;
+ struct device *dma_dev;
dma_cookie_t cookie;
chan = cdns_ctrl->dmac;
- dma_dev = chan->device;
+ dma_dev = dmaengine_get_dma_device(chan);
- buf_dma = dma_map_single(dma_dev->dev, buf, len, dir);
- if (dma_mapping_error(dma_dev->dev, buf_dma)) {
+ buf_dma = dma_map_single(dma_dev, buf, len, dir);
+ if (dma_mapping_error(dma_dev, buf_dma)) {
dev_err(cdns_ctrl->dev, "Failed to map DMA buffer\n");
goto err;
}
@@ -1914,12 +1914,12 @@ static int cadence_nand_slave_dma_transfer(struct cdns_nand_ctrl *cdns_ctrl,
dma_async_issue_pending(cdns_ctrl->dmac);
wait_for_completion(&finished);
- dma_unmap_single(dma_dev->dev, buf_dma, len, dir);
+ dma_unmap_single(dma_dev, buf_dma, len, dir);
return 0;
err_unmap:
- dma_unmap_single(dma_dev->dev, buf_dma, len, dir);
+ dma_unmap_single(dma_dev, buf_dma, len, dir);
err:
dev_dbg(cdns_ctrl->dev, "Fall back to CPU I/O\n");
@@ -3134,8 +3134,8 @@ cadence_nand_irq_cleanup(int irqnum, struct cdns_nand_ctrl *cdns_ctrl)
static int cadence_nand_init(struct cdns_nand_ctrl *cdns_ctrl)
{
+ struct device *dma_dev;
dma_cap_mask_t mask;
- struct dma_device *dma_dev;
int ret;
cdns_ctrl->cdma_desc = dma_alloc_coherent(cdns_ctrl->dev,
@@ -3181,12 +3181,12 @@ static int cadence_nand_init(struct cdns_nand_ctrl *cdns_ctrl)
goto disable_irq;
}
- dma_dev = cdns_ctrl->dmac->device;
- cdns_ctrl->io.iova_dma = dma_map_resource(dma_dev->dev, cdns_ctrl->io.dma,
+ dma_dev = dmaengine_get_dma_device(cdns_ctrl->dmac);
+ cdns_ctrl->io.iova_dma = dma_map_resource(dma_dev, cdns_ctrl->io.dma,
cdns_ctrl->io.size,
DMA_BIDIRECTIONAL, 0);
- ret = dma_mapping_error(dma_dev->dev, cdns_ctrl->io.iova_dma);
+ ret = dma_mapping_error(dma_dev, cdns_ctrl->io.iova_dma);
if (ret) {
dev_err(cdns_ctrl->dev, "Failed to map I/O resource to DMA\n");
goto dma_release_chnl;
@@ -3210,7 +3210,7 @@ static int cadence_nand_init(struct cdns_nand_ctrl *cdns_ctrl)
unmap_dma_resource:
if (cdns_ctrl->dmac)
- dma_unmap_resource(dma_dev->dev, cdns_ctrl->io.iova_dma,
+ dma_unmap_resource(dma_dev, cdns_ctrl->io.iova_dma,
cdns_ctrl->io.size, DMA_BIDIRECTIONAL, 0);
dma_release_chnl:
--
2.56.0
prev parent reply other threads:[~2026-11-24 9:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 9:24 [PATCH v2 0/3] mtd: rawnand: cadence: Fix incorrect variable dereference Miquel Raynal
2026-11-24 9:24 ` [PATCH v2 1/3] mtd: rawnand: cadence: Fix DMA device dereference when DMA is disabled Miquel Raynal
2026-11-24 9:24 ` [PATCH v2 2/3] mtd: rawnand: cadence: Resize the bounce buffer before the BBT scan Miquel Raynal
2026-11-24 9:24 ` Miquel Raynal [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261124-perso-upstreaming-rawnand-fixes-v2-3-69db17ad07bd@bootlin.com \
--to=miquel.raynal@bootlin.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=niravkumarlaxmidas.rabara@altera.com \
--cc=richard@nod.at \
--cc=thomas.petazzoni@bootlin.com \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®