354f12e214649515d885e65ab9a37e051fa01f34
[openwrt/staging/wigyori.git] /
1 From 6f3a5814c7aaea4176e0ac8b1ec6dc0a65aa2808 Mon Sep 17 00:00:00 2001
2 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
3 Date: Sun, 22 May 2022 14:22:07 +0200
4 Subject: [PATCH 09/16] i2c: mediatek: Fix an error handling path in
5 mtk_i2c_probe()
6
7 The clsk are prepared, enabled, then disabled. So if an error occurs after
8 the disable step, they are still prepared.
9
10 Add an error handling path to unprepare the clks in such a case, as already
11 done in the .remove function.
12
13 Fixes: 8b4fc246c3ff ("i2c: mediatek: Optimize master_xfer() and avoid circular locking")
14 Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
15 Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
16 Reviewed-by: Qii Wang <qii.wang@mediatek.com>
17 Signed-off-by: Wolfram Sang <wsa@kernel.org>
18 ---
19 drivers/i2c/busses/i2c-mt65xx.c | 9 +++++++--
20 1 file changed, 7 insertions(+), 2 deletions(-)
21
22 --- a/drivers/i2c/busses/i2c-mt65xx.c
23 +++ b/drivers/i2c/busses/i2c-mt65xx.c
24 @@ -1420,17 +1420,22 @@ static int mtk_i2c_probe(struct platform
25 if (ret < 0) {
26 dev_err(&pdev->dev,
27 "Request I2C IRQ %d fail\n", irq);
28 - return ret;
29 + goto err_bulk_unprepare;
30 }
31
32 i2c_set_adapdata(&i2c->adap, i2c);
33 ret = i2c_add_adapter(&i2c->adap);
34 if (ret)
35 - return ret;
36 + goto err_bulk_unprepare;
37
38 platform_set_drvdata(pdev, i2c);
39
40 return 0;
41 +
42 +err_bulk_unprepare:
43 + clk_bulk_unprepare(I2C_MT65XX_CLK_MAX, i2c->clocks);
44 +
45 + return ret;
46 }
47
48 static int mtk_i2c_remove(struct platform_device *pdev)