Skip to content

Commit c570172

Browse files
avolmat-stgregkh
authored andcommitted
i2c: stm32f7: report dma error during probe
[ Upstream commit d77eceb ] Distinguish between the case where dma information is not provided within the DT and the case of an error during the dma init. Exit the probe with error in case of an error during dma init. Fixes: bb8822c ("i2c: i2c-stm32: Add generic DMA API") Signed-off-by: Alain Volmat <alain.volmat@st.com> Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@st.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f6d3626 commit c570172

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

drivers/i2c/busses/i2c-stm32.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev,
2020

2121
dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL);
2222
if (!dma)
23-
return NULL;
23+
return ERR_PTR(-ENOMEM);
2424

2525
/* Request and configure I2C TX dma channel */
26-
dma->chan_tx = dma_request_slave_channel(dev, "tx");
27-
if (!dma->chan_tx) {
26+
dma->chan_tx = dma_request_chan(dev, "tx");
27+
if (IS_ERR(dma->chan_tx)) {
2828
dev_dbg(dev, "can't request DMA tx channel\n");
29-
ret = -EINVAL;
29+
ret = PTR_ERR(dma->chan_tx);
3030
goto fail_al;
3131
}
3232

@@ -42,10 +42,10 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev,
4242
}
4343

4444
/* Request and configure I2C RX dma channel */
45-
dma->chan_rx = dma_request_slave_channel(dev, "rx");
46-
if (!dma->chan_rx) {
45+
dma->chan_rx = dma_request_chan(dev, "rx");
46+
if (IS_ERR(dma->chan_rx)) {
4747
dev_err(dev, "can't request DMA rx channel\n");
48-
ret = -EINVAL;
48+
ret = PTR_ERR(dma->chan_rx);
4949
goto fail_tx;
5050
}
5151

@@ -75,7 +75,7 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev,
7575
devm_kfree(dev, dma);
7676
dev_info(dev, "can't use DMA\n");
7777

78-
return NULL;
78+
return ERR_PTR(ret);
7979
}
8080

8181
void stm32_i2c_dma_free(struct stm32_i2c_dma *dma)

drivers/i2c/busses/i2c-stm32f7.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,6 +1955,15 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
19551955
i2c_dev->dma = stm32_i2c_dma_request(i2c_dev->dev, phy_addr,
19561956
STM32F7_I2C_TXDR,
19571957
STM32F7_I2C_RXDR);
1958+
if (PTR_ERR(i2c_dev->dma) == -ENODEV)
1959+
i2c_dev->dma = NULL;
1960+
else if (IS_ERR(i2c_dev->dma)) {
1961+
ret = PTR_ERR(i2c_dev->dma);
1962+
if (ret != -EPROBE_DEFER)
1963+
dev_err(&pdev->dev,
1964+
"Failed to request dma error %i\n", ret);
1965+
goto clk_free;
1966+
}
19581967

19591968
platform_set_drvdata(pdev, i2c_dev);
19601969

0 commit comments

Comments
 (0)