Commit 994c5483 authored by Timur Tabi's avatar Timur Tabi Committed by David S. Miller

net: qcom/emac: grab a reference to the phydev on ACPI systems

Commit 6ffe1c4c ("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: default avatarTimur Tabi <timur@codeaurora.org>
Reviewed-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ea7a8085
...@@ -201,6 +201,13 @@ int emac_phy_config(struct platform_device *pdev, struct emac_adapter *adpt) ...@@ -201,6 +201,13 @@ int emac_phy_config(struct platform_device *pdev, struct emac_adapter *adpt)
else else
adpt->phydev = mdiobus_get_phy(mii_bus, phy_addr); adpt->phydev = mdiobus_get_phy(mii_bus, phy_addr);
/* of_phy_find_device() claims a reference to the phydev,
* so we do that here manually as well. When the driver
* later unloads, it can unilaterally drop the reference
* without worrying about ACPI vs DT.
*/
if (adpt->phydev)
get_device(&adpt->phydev->mdio.dev);
} else { } else {
struct device_node *phy_np; struct device_node *phy_np;
......
...@@ -719,8 +719,7 @@ static int emac_probe(struct platform_device *pdev) ...@@ -719,8 +719,7 @@ static int emac_probe(struct platform_device *pdev)
err_undo_napi: err_undo_napi:
netif_napi_del(&adpt->rx_q.napi); netif_napi_del(&adpt->rx_q.napi);
err_undo_mdiobus: err_undo_mdiobus:
if (!has_acpi_companion(&pdev->dev)) put_device(&adpt->phydev->mdio.dev);
put_device(&adpt->phydev->mdio.dev);
mdiobus_unregister(adpt->mii_bus); mdiobus_unregister(adpt->mii_bus);
err_undo_clocks: err_undo_clocks:
emac_clks_teardown(adpt); emac_clks_teardown(adpt);
...@@ -740,8 +739,7 @@ static int emac_remove(struct platform_device *pdev) ...@@ -740,8 +739,7 @@ static int emac_remove(struct platform_device *pdev)
emac_clks_teardown(adpt); emac_clks_teardown(adpt);
if (!has_acpi_companion(&pdev->dev)) put_device(&adpt->phydev->mdio.dev);
put_device(&adpt->phydev->mdio.dev);
mdiobus_unregister(adpt->mii_bus); mdiobus_unregister(adpt->mii_bus);
free_netdev(netdev); free_netdev(netdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment