Skip to content

Commit de87b60

Browse files
tititiou36wsakernel
authored andcommitted
i2c: mediatek: Fix an error handling path in mtk_i2c_probe()
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: 8b4fc24 ("i2c: mediatek: Optimize master_xfer() and avoid circular locking") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Qii Wang <qii.wang@mediatek.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
1 parent 27071b5 commit de87b60

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/i2c/busses/i2c-mt65xx.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,17 +1420,22 @@ static int mtk_i2c_probe(struct platform_device *pdev)
14201420
if (ret < 0) {
14211421
dev_err(&pdev->dev,
14221422
"Request I2C IRQ %d fail\n", irq);
1423-
return ret;
1423+
goto err_bulk_unprepare;
14241424
}
14251425

14261426
i2c_set_adapdata(&i2c->adap, i2c);
14271427
ret = i2c_add_adapter(&i2c->adap);
14281428
if (ret)
1429-
return ret;
1429+
goto err_bulk_unprepare;
14301430

14311431
platform_set_drvdata(pdev, i2c);
14321432

14331433
return 0;
1434+
1435+
err_bulk_unprepare:
1436+
clk_bulk_unprepare(I2C_MT65XX_CLK_MAX, i2c->clocks);
1437+
1438+
return ret;
14341439
}
14351440

14361441
static int mtk_i2c_remove(struct platform_device *pdev)

0 commit comments

Comments
 (0)