kernel: bump 5.4 to 5.4.109
[openwrt/openwrt.git] / target / linux / layerscape / patches-5.4 / 808-i2c-0016-LF-162-i2c-imx-Defer-probing-if-EDMA-not-available.patch
1 From 9de3b340d84b75f93081f871b640a065cba4ded0 Mon Sep 17 00:00:00 2001
2 From: Peng Ma <peng.ma@nxp.com>
3 Date: Tue, 26 Nov 2019 16:02:00 +0800
4 Subject: [PATCH] LF-162: i2c: imx: Defer probing if EDMA not available
5
6 EDMA may be not available or defered due to dependencies on
7 other modules, If these scenarios is encountered, we should
8 defer probing.
9
10 Signed-off-by: Peng Ma <peng.ma@nxp.com>
11 ---
12 drivers/i2c/busses/i2c-imx.c | 16 +++++++++++-----
13 1 file changed, 11 insertions(+), 5 deletions(-)
14
15 --- a/drivers/i2c/busses/i2c-imx.c
16 +++ b/drivers/i2c/busses/i2c-imx.c
17 @@ -369,8 +369,8 @@ static void i2c_imx_reset_regs(struct im
18 }
19
20 /* Functions for DMA support */
21 -static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
22 - dma_addr_t phy_addr)
23 +static int i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
24 + dma_addr_t phy_addr)
25 {
26 struct imx_i2c_dma *dma;
27 struct dma_slave_config dma_sconfig;
28 @@ -379,7 +379,7 @@ static void i2c_imx_dma_request(struct i
29
30 dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL);
31 if (!dma)
32 - return;
33 + return -ENOMEM;
34
35 dma->chan_tx = dma_request_chan(dev, "tx");
36 if (IS_ERR(dma->chan_tx)) {
37 @@ -424,7 +424,7 @@ static void i2c_imx_dma_request(struct i
38 dev_info(dev, "using %s (tx) and %s (rx) for DMA transfers\n",
39 dma_chan_name(dma->chan_tx), dma_chan_name(dma->chan_rx));
40
41 - return;
42 + return 0;
43
44 fail_rx:
45 dma_release_channel(dma->chan_rx);
46 @@ -432,6 +432,8 @@ fail_tx:
47 dma_release_channel(dma->chan_tx);
48 fail_al:
49 devm_kfree(dev, dma);
50 +
51 + return ret;
52 }
53
54 static void i2c_imx_dma_callback(void *arg)
55 @@ -1633,10 +1635,14 @@ static int i2c_imx_probe(struct platform
56 dev_info(&i2c_imx->adapter.dev, "IMX I2C adapter registered\n");
57
58 /* Init DMA config if supported */
59 - i2c_imx_dma_request(i2c_imx, phy_addr);
60 + ret = i2c_imx_dma_request(i2c_imx, phy_addr);
61 + if (ret == -EPROBE_DEFER)
62 + goto i2c_adapter_remove;
63
64 return 0; /* Return OK */
65
66 +i2c_adapter_remove:
67 + i2c_del_adapter(&i2c_imx->adapter);
68 clk_notifier_unregister:
69 clk_notifier_unregister(i2c_imx->clk, &i2c_imx->clk_change_nb);
70 free_irq(irq, i2c_imx);