From: Alain Volmat <alain.volmat@st.com>
To: <wsa@kernel.org>, <pierre-yves.mordret@st.com>
Cc: <alexandre.torgue@st.com>, <linux-i2c@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <fabrice.gasnier@st.com>,
<alain.volmat@st.com>
Subject: [PATCH] i2c: stm32: do not display error when DMA is not requested
Date: Thu, 10 Sep 2020 11:32:29 +0200 [thread overview]
Message-ID: <1599730349-2160-1-git-send-email-alain.volmat@st.com> (raw)
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
next reply other threads:[~2020-09-10 9:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-10 9:32 Alain Volmat [this message]
2020-09-10 10:06 ` [PATCH] i2c: stm32: do not display error when DMA is not requested Wolfram Sang
2020-09-10 12:27 ` Alain Volmat
2020-09-10 12:50 ` Wolfram Sang
2020-09-10 13:35 ` Krzysztof Kozlowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1599730349-2160-1-git-send-email-alain.volmat@st.com \
--to=alain.volmat@st.com \
--cc=alexandre.torgue@st.com \
--cc=fabrice.gasnier@st.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=pierre-yves.mordret@st.com \
--cc=wsa@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).