0107-i2c_bcm2708-Fix-clock-reference-counting.patch 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. From cf1b789e1a6873d9680156fac9f675a0f1cdd17b Mon Sep 17 00:00:00 2001
  2. From: Phil Elwell <phil@raspberrypi.org>
  3. Date: Thu, 5 Feb 2015 16:01:44 +0000
  4. Subject: [PATCH 107/114] i2c_bcm2708: Fix clock reference counting
  5. ---
  6. drivers/i2c/busses/i2c-bcm2708.c | 12 ++++++++++--
  7. 1 file changed, 10 insertions(+), 2 deletions(-)
  8. --- a/drivers/i2c/busses/i2c-bcm2708.c
  9. +++ b/drivers/i2c/busses/i2c-bcm2708.c
  10. @@ -337,11 +337,17 @@ static int bcm2708_i2c_probe(struct plat
  11. return PTR_ERR(clk);
  12. }
  13. + err = clk_prepare_enable(clk);
  14. + if (err) {
  15. + dev_err(&pdev->dev, "could not enable clk: %d\n", err);
  16. + goto out_clk_put;
  17. + }
  18. +
  19. bcm2708_i2c_init_pinmode(pdev->id);
  20. bi = kzalloc(sizeof(*bi), GFP_KERNEL);
  21. if (!bi)
  22. - goto out_clk_put;
  23. + goto out_clk_disable;
  24. platform_set_drvdata(pdev, bi);
  25. @@ -412,6 +418,8 @@ out_iounmap:
  26. iounmap(bi->base);
  27. out_free_bi:
  28. kfree(bi);
  29. +out_clk_disable:
  30. + clk_disable_unprepare(clk);
  31. out_clk_put:
  32. clk_put(clk);
  33. return err;
  34. @@ -426,7 +434,7 @@ static int bcm2708_i2c_remove(struct pla
  35. i2c_del_adapter(&bi->adapter);
  36. free_irq(bi->irq, bi);
  37. iounmap(bi->base);
  38. - clk_disable(bi->clk);
  39. + clk_disable_unprepare(bi->clk);
  40. clk_put(bi->clk);
  41. kfree(bi);