Commit c870cbbd authored by Clément Le Goffic's avatar Clément Le Goffic Committed by Andi Shyti
Browse files

i2c: stm32: fix the device used for the DMA map



If the DMA mapping failed, it produced an error log with the wrong
device name:
"stm32-dma3 40400000.dma-controller: rejecting DMA map of vmalloc memory"
Fix this issue by replacing the dev with the I2C dev.

Fixes: bb8822cb ("i2c: i2c-stm32: Add generic DMA API")
Signed-off-by: default avatarClément Le Goffic <clement.legoffic@foss.st.com>
Cc: <stable@vger.kernel.org> # v4.18+
Acked-by: default avatarAlain Volmat <alain.volmat@foss.st.com>
Signed-off-by: default avatarAndi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20250704-i2c-upstream-v4-1-84a095a2c728@foss.st.com
parent 60c016af
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -102,7 +102,6 @@ int stm32_i2c_prep_dma_xfer(struct device *dev, struct stm32_i2c_dma *dma,
			    void *dma_async_param)
{
	struct dma_async_tx_descriptor *txdesc;
	struct device *chan_dev;
	int ret;

	if (rd_wr) {
@@ -116,11 +115,10 @@ int stm32_i2c_prep_dma_xfer(struct device *dev, struct stm32_i2c_dma *dma,
	}

	dma->dma_len = len;
	chan_dev = dma->chan_using->device->dev;

	dma->dma_buf = dma_map_single(chan_dev, buf, dma->dma_len,
	dma->dma_buf = dma_map_single(dev, buf, dma->dma_len,
				      dma->dma_data_dir);
	if (dma_mapping_error(chan_dev, dma->dma_buf)) {
	if (dma_mapping_error(dev, dma->dma_buf)) {
		dev_err(dev, "DMA mapping failed\n");
		return -EINVAL;
	}
@@ -150,7 +148,7 @@ int stm32_i2c_prep_dma_xfer(struct device *dev, struct stm32_i2c_dma *dma,
	return 0;

err:
	dma_unmap_single(chan_dev, dma->dma_buf, dma->dma_len,
	dma_unmap_single(dev, dma->dma_buf, dma->dma_len,
			 dma->dma_data_dir);
	return ret;
}
+2 −2
Original line number Diff line number Diff line
@@ -741,10 +741,10 @@ static void stm32f7_i2c_dma_callback(void *arg)
{
	struct stm32f7_i2c_dev *i2c_dev = (struct stm32f7_i2c_dev *)arg;
	struct stm32_i2c_dma *dma = i2c_dev->dma;
	struct device *dev = dma->chan_using->device->dev;

	stm32f7_i2c_disable_dma_req(i2c_dev);
	dma_unmap_single(dev, dma->dma_buf, dma->dma_len, dma->dma_data_dir);
	dma_unmap_single(i2c_dev->dev, dma->dma_buf, dma->dma_len,
			 dma->dma_data_dir);
	complete(&dma->dma_complete);
}