2
0

001-4.15-08-bcm63xx_enet-correct-clock-usage.patch 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. From d0423d3e4fa7ae305729cb50369427f075ccb279 Mon Sep 17 00:00:00 2001
  2. From: Jonas Gorski <[email protected]>
  3. Date: Sat, 25 Feb 2017 12:41:28 +0100
  4. Subject: [PATCH 1/6] bcm63xx_enet: correct clock usage
  5. Check the return code of prepare_enable and change one last instance of
  6. enable only to prepare_enable. Also properly disable and release the
  7. clock in error paths and on remove for enetsw.
  8. Signed-off-by: Jonas Gorski <[email protected]>
  9. ---
  10. drivers/net/ethernet/broadcom/bcm63xx_enet.c | 31 +++++++++++++++++++++-------
  11. 1 file changed, 23 insertions(+), 8 deletions(-)
  12. --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
  13. +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
  14. @@ -1790,7 +1790,9 @@ static int bcm_enet_probe(struct platfor
  15. ret = PTR_ERR(priv->mac_clk);
  16. goto out;
  17. }
  18. - clk_prepare_enable(priv->mac_clk);
  19. + ret = clk_prepare_enable(priv->mac_clk);
  20. + if (ret)
  21. + goto out_put_clk_mac;
  22. /* initialize default and fetch platform data */
  23. priv->rx_ring_size = BCMENET_DEF_RX_DESC;
  24. @@ -1822,9 +1824,11 @@ static int bcm_enet_probe(struct platfor
  25. if (IS_ERR(priv->phy_clk)) {
  26. ret = PTR_ERR(priv->phy_clk);
  27. priv->phy_clk = NULL;
  28. - goto out_put_clk_mac;
  29. + goto out_disable_clk_mac;
  30. }
  31. - clk_prepare_enable(priv->phy_clk);
  32. + ret = clk_prepare_enable(priv->phy_clk);
  33. + if (ret)
  34. + goto out_put_clk_phy;
  35. }
  36. /* do minimal hardware init to be able to probe mii bus */
  37. @@ -1915,13 +1919,16 @@ out_free_mdio:
  38. out_uninit_hw:
  39. /* turn off mdc clock */
  40. enet_writel(priv, 0, ENET_MIISC_REG);
  41. - if (priv->phy_clk) {
  42. + if (priv->phy_clk)
  43. clk_disable_unprepare(priv->phy_clk);
  44. +
  45. +out_put_clk_phy:
  46. + if (priv->phy_clk)
  47. clk_put(priv->phy_clk);
  48. - }
  49. -out_put_clk_mac:
  50. +out_disable_clk_mac:
  51. clk_disable_unprepare(priv->mac_clk);
  52. +out_put_clk_mac:
  53. clk_put(priv->mac_clk);
  54. out:
  55. free_netdev(dev);
  56. @@ -2766,7 +2773,9 @@ static int bcm_enetsw_probe(struct platf
  57. ret = PTR_ERR(priv->mac_clk);
  58. goto out_unmap;
  59. }
  60. - clk_enable(priv->mac_clk);
  61. + ret = clk_prepare_enable(priv->mac_clk);
  62. + if (ret)
  63. + goto out_put_clk;
  64. priv->rx_chan = 0;
  65. priv->tx_chan = 1;
  66. @@ -2787,7 +2796,7 @@ static int bcm_enetsw_probe(struct platf
  67. ret = register_netdev(dev);
  68. if (ret)
  69. - goto out_put_clk;
  70. + goto out_disable_clk;
  71. netif_carrier_off(dev);
  72. platform_set_drvdata(pdev, dev);
  73. @@ -2796,6 +2805,9 @@ static int bcm_enetsw_probe(struct platf
  74. return 0;
  75. +out_disable_clk:
  76. + clk_disable_unprepare(priv->mac_clk);
  77. +
  78. out_put_clk:
  79. clk_put(priv->mac_clk);
  80. @@ -2827,6 +2839,9 @@ static int bcm_enetsw_remove(struct plat
  81. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  82. release_mem_region(res->start, resource_size(res));
  83. + clk_disable_unprepare(priv->mac_clk);
  84. + clk_put(priv->mac_clk);
  85. +
  86. free_netdev(dev);
  87. return 0;
  88. }