[PATCH] i2c: stm32: do not display error when DMA is not requested
Alain Volmat
alain.volmat at st.com
Thu Sep 10 05:32:29 EDT 2020
DMA usage is optional for the I2C driver. check for the -ENODEV
error in order to avoid displaying an error when no DMA
has been requested.
Signed-off-by: Alain Volmat <alain.volmat at st.com>
---
This patch should be applied on top of the patch [i2c: stm32: Simplify with dev_err_probe()]
---
drivers/i2c/busses/i2c-stm32.c | 16 ++++++++++------
drivers/i2c/busses/i2c-stm32f7.c | 5 +++++
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/drivers/i2c/busses/i2c-stm32.c b/drivers/i2c/busses/i2c-stm32.c
index 198f848b7be9..91767156d63d 100644
--- a/drivers/i2c/busses/i2c-stm32.c
+++ b/drivers/i2c/busses/i2c-stm32.c
@@ -25,8 +25,11 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev,
/* Request and configure I2C TX dma channel */
dma->chan_tx = dma_request_chan(dev, "tx");
if (IS_ERR(dma->chan_tx)) {
- ret = dev_err_probe(dev, PTR_ERR(dma->chan_tx),
- "can't request DMA tx channel\n");
+ if (PTR_ERR(dma->chan_tx) == -ENODEV)
+ ret = PTR_ERR(dma->chan_tx);
+ else
+ ret = dev_err_probe(dev, PTR_ERR(dma->chan_tx),
+ "can't request DMA tx channel\n");
goto fail_al;
}
@@ -44,8 +47,11 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev,
/* Request and configure I2C RX dma channel */
dma->chan_rx = dma_request_chan(dev, "rx");
if (IS_ERR(dma->chan_rx)) {
- ret = dev_err_probe(dev, PTR_ERR(dma->chan_rx),
- "can't request DMA rx channel\n");
+ if (PTR_ERR(dma->chan_tx) == -ENODEV)
+ ret = PTR_ERR(dma->chan_tx);
+ else
+ ret = dev_err_probe(dev, PTR_ERR(dma->chan_rx),
+ "can't request DMA rx channel\n");
goto fail_tx;
}
@@ -73,8 +79,6 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev,
dma_release_channel(dma->chan_tx);
fail_al:
devm_kfree(dev, dma);
- if (ret != -EPROBE_DEFER)
- dev_info(dev, "can't use DMA\n");
return ERR_PTR(ret);
}
diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
index a8f1758e4c5b..58f342aea3c1 100644
--- a/drivers/i2c/busses/i2c-stm32f7.c
+++ b/drivers/i2c/busses/i2c-stm32f7.c
@@ -2049,6 +2049,11 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
STM32F7_I2C_TXDR,
STM32F7_I2C_RXDR);
if (PTR_ERR(i2c_dev->dma) == -ENODEV) {
+ /*
+ * DMA usage is not mandatory for the I2C, it is not an error
+ * to receive -ENODEV
+ */
+ dev_dbg(i2c_dev->dev, "not using DMA\n");
i2c_dev->dma = NULL;
} else if (IS_ERR(i2c_dev->dma)) {
ret = dev_err_probe(&pdev->dev, PTR_ERR(i2c_dev->dma),
--
2.7.4
More information about the linux-arm-kernel
mailing list