848-v5.19-i2c-mediatek-Fix-an-error-handling-path-in-mtk_i2c_p.patch 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. From 6f3a5814c7aaea4176e0ac8b1ec6dc0a65aa2808 Mon Sep 17 00:00:00 2001
  2. From: Christophe JAILLET <[email protected]>
  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. The clsk are prepared, enabled, then disabled. So if an error occurs after
  7. the disable step, they are still prepared.
  8. Add an error handling path to unprepare the clks in such a case, as already
  9. done in the .remove function.
  10. Fixes: 8b4fc246c3ff ("i2c: mediatek: Optimize master_xfer() and avoid circular locking")
  11. Signed-off-by: Christophe JAILLET <[email protected]>
  12. Reviewed-by: AngeloGioacchino Del Regno <[email protected]>
  13. Reviewed-by: Qii Wang <[email protected]>
  14. Signed-off-by: Wolfram Sang <[email protected]>
  15. ---
  16. drivers/i2c/busses/i2c-mt65xx.c | 9 +++++++--
  17. 1 file changed, 7 insertions(+), 2 deletions(-)
  18. --- a/drivers/i2c/busses/i2c-mt65xx.c
  19. +++ b/drivers/i2c/busses/i2c-mt65xx.c
  20. @@ -1420,17 +1420,22 @@ static int mtk_i2c_probe(struct platform
  21. if (ret < 0) {
  22. dev_err(&pdev->dev,
  23. "Request I2C IRQ %d fail\n", irq);
  24. - return ret;
  25. + goto err_bulk_unprepare;
  26. }
  27. i2c_set_adapdata(&i2c->adap, i2c);
  28. ret = i2c_add_adapter(&i2c->adap);
  29. if (ret)
  30. - return ret;
  31. + goto err_bulk_unprepare;
  32. platform_set_drvdata(pdev, i2c);
  33. return 0;
  34. +
  35. +err_bulk_unprepare:
  36. + clk_bulk_unprepare(I2C_MT65XX_CLK_MAX, i2c->clocks);
  37. +
  38. + return ret;
  39. }
  40. static int mtk_i2c_remove(struct platform_device *pdev)