linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: mediatek: Fix an error handling path in mtk_i2c_probe()
@ 2022-05-22 12:22 Christophe JAILLET
  2022-05-23  8:41 ` AngeloGioacchino Del Regno
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Christophe JAILLET @ 2022-05-22 12:22 UTC (permalink / raw)
  To: dan.carpenter, Qii Wang, Matthias Brugger,
	AngeloGioacchino Del Regno, Wolfram Sang
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-i2c,
	linux-arm-kernel, linux-mediatek

The clsk are prepared, enabled, then disabled. So if an error occurs after
the disable step, they are still prepared.

Add an error handling path to unprepare the clks in such a case, as already
done in the .remove function.

Fixes: 8b4fc246c3ff ("i2c: mediatek: Optimize master_xfer() and avoid circular locking")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/i2c/busses/i2c-mt65xx.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
index bdecb78bfc26..8e6985354fd5 100644
--- a/drivers/i2c/busses/i2c-mt65xx.c
+++ b/drivers/i2c/busses/i2c-mt65xx.c
@@ -1420,17 +1420,22 @@ static int mtk_i2c_probe(struct platform_device *pdev)
 	if (ret < 0) {
 		dev_err(&pdev->dev,
 			"Request I2C IRQ %d fail\n", irq);
-		return ret;
+		goto err_bulk_unprepare;
 	}
 
 	i2c_set_adapdata(&i2c->adap, i2c);
 	ret = i2c_add_adapter(&i2c->adap);
 	if (ret)
-		return ret;
+		goto err_bulk_unprepare;
 
 	platform_set_drvdata(pdev, i2c);
 
 	return 0;
+
+err_bulk_unprepare:
+	clk_bulk_unprepare(I2C_MT65XX_CLK_MAX, i2c->clocks);
+
+	return ret;
 }
 
 static int mtk_i2c_remove(struct platform_device *pdev)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] i2c: mediatek: Fix an error handling path in mtk_i2c_probe()
  2022-05-22 12:22 [PATCH] i2c: mediatek: Fix an error handling path in mtk_i2c_probe() Christophe JAILLET
@ 2022-05-23  8:41 ` AngeloGioacchino Del Regno
  2022-05-26 11:31 ` Qii Wang
  2022-06-14 20:12 ` Wolfram Sang
  2 siblings, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-05-23  8:41 UTC (permalink / raw)
  To: Christophe JAILLET, dan.carpenter, Qii Wang, Matthias Brugger,
	Wolfram Sang
  Cc: linux-kernel, kernel-janitors, linux-i2c, linux-arm-kernel,
	linux-mediatek

Il 22/05/22 14:22, Christophe JAILLET ha scritto:
> The clsk are prepared, enabled, then disabled. So if an error occurs after
> the disable step, they are still prepared.
> 
> Add an error handling path to unprepare the clks in such a case, as already
> done in the .remove function.
> 
> Fixes: 8b4fc246c3ff ("i2c: mediatek: Optimize master_xfer() and avoid circular locking")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Thanks!

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] i2c: mediatek: Fix an error handling path in mtk_i2c_probe()
  2022-05-22 12:22 [PATCH] i2c: mediatek: Fix an error handling path in mtk_i2c_probe() Christophe JAILLET
  2022-05-23  8:41 ` AngeloGioacchino Del Regno
@ 2022-05-26 11:31 ` Qii Wang
  2022-06-14 20:12 ` Wolfram Sang
  2 siblings, 0 replies; 4+ messages in thread
From: Qii Wang @ 2022-05-26 11:31 UTC (permalink / raw)
  To: Christophe JAILLET, dan.carpenter, Matthias Brugger,
	AngeloGioacchino Del Regno, Wolfram Sang
  Cc: linux-kernel, kernel-janitors, linux-i2c, linux-arm-kernel,
	linux-mediatek

On Sun, 2022-05-22 at 14:22 +0200, Christophe JAILLET wrote:
> The clsk are prepared, enabled, then disabled. So if an error occurs
> after
> the disable step, they are still prepared.
> 
> Add an error handling path to unprepare the clks in such a case, as
> already
> done in the .remove function.
> 
> Fixes: 8b4fc246c3ff ("i2c: mediatek: Optimize master_xfer() and avoid
> circular locking")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-by: Qii Wang <qii.wang@mediatek.com>

> ---
>  drivers/i2c/busses/i2c-mt65xx.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] i2c: mediatek: Fix an error handling path in mtk_i2c_probe()
  2022-05-22 12:22 [PATCH] i2c: mediatek: Fix an error handling path in mtk_i2c_probe() Christophe JAILLET
  2022-05-23  8:41 ` AngeloGioacchino Del Regno
  2022-05-26 11:31 ` Qii Wang
@ 2022-06-14 20:12 ` Wolfram Sang
  2 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2022-06-14 20:12 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: dan.carpenter, Qii Wang, Matthias Brugger,
	AngeloGioacchino Del Regno, linux-kernel, kernel-janitors,
	linux-i2c, linux-arm-kernel, linux-mediatek

[-- Attachment #1: Type: text/plain, Size: 511 bytes --]

On Sun, May 22, 2022 at 02:22:07PM +0200, Christophe JAILLET wrote:
> The clsk are prepared, enabled, then disabled. So if an error occurs after
> the disable step, they are still prepared.
> 
> Add an error handling path to unprepare the clks in such a case, as already
> done in the .remove function.
> 
> Fixes: 8b4fc246c3ff ("i2c: mediatek: Optimize master_xfer() and avoid circular locking")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied to for-current, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-06-14 20:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-22 12:22 [PATCH] i2c: mediatek: Fix an error handling path in mtk_i2c_probe() Christophe JAILLET
2022-05-23  8:41 ` AngeloGioacchino Del Regno
2022-05-26 11:31 ` Qii Wang
2022-06-14 20:12 ` Wolfram Sang

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