Skip to content

Commit c870cbb

Browse files
UpsylonbareAndi Shyti
authored andcommitted
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: bb8822c ("i2c: i2c-stm32: Add generic DMA API") Signed-off-by: Clément Le Goffic <[email protected]> Cc: <[email protected]> # v4.18+ Acked-by: Alain Volmat <[email protected]> Signed-off-by: Andi Shyti <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 60c016a commit c870cbb

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

drivers/i2c/busses/i2c-stm32.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ int stm32_i2c_prep_dma_xfer(struct device *dev, struct stm32_i2c_dma *dma,
102102
void *dma_async_param)
103103
{
104104
struct dma_async_tx_descriptor *txdesc;
105-
struct device *chan_dev;
106105
int ret;
107106

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

118117
dma->dma_len = len;
119-
chan_dev = dma->chan_using->device->dev;
120118

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

152150
err:
153-
dma_unmap_single(chan_dev, dma->dma_buf, dma->dma_len,
151+
dma_unmap_single(dev, dma->dma_buf, dma->dma_len,
154152
dma->dma_data_dir);
155153
return ret;
156154
}

drivers/i2c/busses/i2c-stm32f7.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,10 +741,10 @@ static void stm32f7_i2c_dma_callback(void *arg)
741741
{
742742
struct stm32f7_i2c_dev *i2c_dev = (struct stm32f7_i2c_dev *)arg;
743743
struct stm32_i2c_dma *dma = i2c_dev->dma;
744-
struct device *dev = dma->chan_using->device->dev;
745744

746745
stm32f7_i2c_disable_dma_req(i2c_dev);
747-
dma_unmap_single(dev, dma->dma_buf, dma->dma_len, dma->dma_data_dir);
746+
dma_unmap_single(i2c_dev->dev, dma->dma_buf, dma->dma_len,
747+
dma->dma_data_dir);
748748
complete(&dma->dma_complete);
749749
}
750750

0 commit comments

Comments
 (0)