[PATCH] i2c: layerscape: use PIO when fail to request dma channel

From: Qiang Zhao
Date: Thu May 23 2019 - 23:06:37 EST


When fail to request DMA TX/RX channel, use PIO instead for layerscape.

Signed-off-by: Zhao Qiang <qiang.zhao@xxxxxxx>
---
drivers/i2c/busses/i2c-imx.c | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 98b278613cf2..39a5ab4cf332 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -347,9 +347,13 @@ static int i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,

dma->chan_tx = dma_request_chan(dev, "tx");
if (IS_ERR(dma->chan_tx)) {
+#ifdef CONFIG_ARCH_LAYERSCAPE
+ dev_dbg(dev, "can't request DMA tx channel\n");
+#else
ret = PTR_ERR(dma->chan_tx);
if (ret != -ENODEV && ret != -EPROBE_DEFER)
dev_err(dev, "can't request DMA tx channel (%d)\n", ret);
+#endif
goto fail_al;
}

@@ -366,9 +370,13 @@ static int i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,

dma->chan_rx = dma_request_chan(dev, "rx");
if (IS_ERR(dma->chan_rx)) {
+#ifdef CONFIG_ARCH_LAYERSCAPE
+ dev_dbg(dev, "can't request DMA rx channel\n");
+#else
ret = PTR_ERR(dma->chan_rx);
if (ret != -ENODEV && ret != -EPROBE_DEFER)
dev_err(dev, "can't request DMA rx channel (%d)\n", ret);
+#endif
goto fail_tx;
}

@@ -396,6 +404,9 @@ static int i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
dma_release_channel(dma->chan_tx);
fail_al:
devm_kfree(dev, dma);
+#ifdef CONFIG_ARCH_LAYERSCAPE
+ dev_info(dev, "can't use DMA, using PIO instead.\n");
+#endif
/* return successfully if there is no dma support */
return ret == -ENODEV ? 0 : ret;
}
--
2.17.1