diff mbox series

i2c: stm32: do not display error when DMA is not requested

Message ID 1599730349-2160-1-git-send-email-alain.volmat@st.com (mailing list archive)
State New, archived
Headers show
Series i2c: stm32: do not display error when DMA is not requested | expand

Commit Message

Alain Volmat Sept. 10, 2020, 9:32 a.m. UTC
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(-)

Comments

Wolfram Sang Sept. 10, 2020, 10:06 a.m. UTC | #1
On Thu, Sep 10, 2020 at 11:32:29AM +0200, Alain Volmat wrote:
> 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()]

We can do it in this order, it just makes backporting to stable kernels
(if that is desired) a bit harder than a self-contained patch. I am fine
with both approaches, but just wanted to point it out.
Alain Volmat Sept. 10, 2020, 12:27 p.m. UTC | #2
On Thu, Sep 10, 2020 at 12:06:07PM +0200, Wolfram Sang wrote:
> On Thu, Sep 10, 2020 at 11:32:29AM +0200, Alain Volmat wrote:
> > 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()]
> 
> We can do it in this order, it just makes backporting to stable kernels
> (if that is desired) a bit harder than a self-contained patch. I am fine
> with both approaches, but just wanted to point it out.

Indeed, that's a good point. I'll rework it then, to avoid the dependency
on dev_err_probe change. If that is ok, I propose to push a two patches serie
with both this fix (updated) followed by a rebased version of the
dev_err_probe patch from Krzysztof for dev_err_probe change.
Wolfram Sang Sept. 10, 2020, 12:50 p.m. UTC | #3
> Indeed, that's a good point. I'll rework it then, to avoid the dependency
> on dev_err_probe change. If that is ok, I propose to push a two patches serie
> with both this fix (updated) followed by a rebased version of the
> dev_err_probe patch from Krzysztof for dev_err_probe change.

Perfect!
Krzysztof Kozlowski Sept. 10, 2020, 1:35 p.m. UTC | #4
On Thu, 10 Sep 2020 at 14:27, Alain Volmat <alain.volmat@st.com> wrote:
>
> On Thu, Sep 10, 2020 at 12:06:07PM +0200, Wolfram Sang wrote:
> > On Thu, Sep 10, 2020 at 11:32:29AM +0200, Alain Volmat wrote:
> > > 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()]
> >
> > We can do it in this order, it just makes backporting to stable kernels
> > (if that is desired) a bit harder than a self-contained patch. I am fine
> > with both approaches, but just wanted to point it out.
>
> Indeed, that's a good point. I'll rework it then, to avoid the dependency
> on dev_err_probe change. If that is ok, I propose to push a two patches serie
> with both this fix (updated) followed by a rebased version of the
> dev_err_probe patch from Krzysztof for dev_err_probe change.

I can rebase mine on top of yours. Indeed such cleanups as mine should
be rather later in the queue.

Best regards,
Krzysztof
diff mbox series

Patch

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),