linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: stm32: do not display error when DMA is not requested
@ 2020-09-10  9:32 Alain Volmat
  2020-09-10 10:06 ` Wolfram Sang
  0 siblings, 1 reply; 5+ messages in thread
From: Alain Volmat @ 2020-09-10  9:32 UTC (permalink / raw)
  To: wsa, pierre-yves.mordret
  Cc: alexandre.torgue, linux-i2c, linux-stm32, linux-arm-kernel,
	linux-kernel, fabrice.gasnier, alain.volmat

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@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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-10 21:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-10  9:32 [PATCH] i2c: stm32: do not display error when DMA is not requested Alain Volmat
2020-09-10 10:06 ` Wolfram Sang
2020-09-10 12:27   ` Alain Volmat
2020-09-10 12:50     ` Wolfram Sang
2020-09-10 13:35     ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).