aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimur Tabi <timur@codeaurora.org>2017-01-11 17:45:51 -0500
committerDavid S. Miller <davem@davemloft.net>2017-01-12 15:13:18 -0500
commit994c5483e7f6dbf9fea622ba2031b9d868feb4b9 (patch)
tree4fd095c82f487d1939d8201945e4334e4bdc3796
parentea7a80858f57d8878b1499ea0f1b8a635cc48de7 (diff)
net: qcom/emac: grab a reference to the phydev on ACPI systems
Commit 6ffe1c4cd0a7 ("net: qcom/emac: fix of_node and phydev leaks") fixed the problem with reference leaks on phydev, but the fix is device-tree specific. When the driver unloads, the reference is dropped only on DT systems. Instead, it's cleaner if up grab an reference on ACPI systems. When the driver unloads, we can drop the reference without having to check whether we're on a DT system. Signed-off-by: Timur Tabi <timur@codeaurora.org> Reviewed-by: Johan Hovold <johan@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/qualcomm/emac/emac-phy.c7
-rw-r--r--drivers/net/ethernet/qualcomm/emac/emac.c6
2 files changed, 9 insertions, 4 deletions
diff --git a/drivers/net/ethernet/qualcomm/emac/emac-phy.c b/drivers/net/ethernet/qualcomm/emac/emac-phy.c
index 99a14df28b96..2851b4c56570 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac-phy.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac-phy.c
@@ -201,6 +201,13 @@ int emac_phy_config(struct platform_device *pdev, struct emac_adapter *adpt)
201 else 201 else
202 adpt->phydev = mdiobus_get_phy(mii_bus, phy_addr); 202 adpt->phydev = mdiobus_get_phy(mii_bus, phy_addr);
203 203
204 /* of_phy_find_device() claims a reference to the phydev,
205 * so we do that here manually as well. When the driver
206 * later unloads, it can unilaterally drop the reference
207 * without worrying about ACPI vs DT.
208 */
209 if (adpt->phydev)
210 get_device(&adpt->phydev->mdio.dev);
204 } else { 211 } else {
205 struct device_node *phy_np; 212 struct device_node *phy_np;
206 213
diff --git a/drivers/net/ethernet/qualcomm/emac/emac.c b/drivers/net/ethernet/qualcomm/emac/emac.c
index 422289c232bc..f46d300bd585 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac.c
@@ -719,8 +719,7 @@ static int emac_probe(struct platform_device *pdev)
719err_undo_napi: 719err_undo_napi:
720 netif_napi_del(&adpt->rx_q.napi); 720 netif_napi_del(&adpt->rx_q.napi);
721err_undo_mdiobus: 721err_undo_mdiobus:
722 if (!has_acpi_companion(&pdev->dev)) 722 put_device(&adpt->phydev->mdio.dev);
723 put_device(&adpt->phydev->mdio.dev);
724 mdiobus_unregister(adpt->mii_bus); 723 mdiobus_unregister(adpt->mii_bus);
725err_undo_clocks: 724err_undo_clocks:
726 emac_clks_teardown(adpt); 725 emac_clks_teardown(adpt);
@@ -740,8 +739,7 @@ static int emac_remove(struct platform_device *pdev)
740 739
741 emac_clks_teardown(adpt); 740 emac_clks_teardown(adpt);
742 741
743 if (!has_acpi_companion(&pdev->dev)) 742 put_device(&adpt->phydev->mdio.dev);
744 put_device(&adpt->phydev->mdio.dev);
745 mdiobus_unregister(adpt->mii_bus); 743 mdiobus_unregister(adpt->mii_bus);
746 free_netdev(netdev); 744 free_netdev(netdev);
747 745