Commit d961a58d authored by Chuhong Yuan's avatar Chuhong Yuan Committed by Greg Kroah-Hartman
Browse files

net: fec: fix clock count mis-match

commit a31eda65 upstream.

pm_runtime_put_autosuspend in probe will call runtime suspend to
disable clks automatically if CONFIG_PM is defined. (If CONFIG_PM
is not defined, its implementation will be empty, then runtime
suspend will not be called.)

Therefore, we can call pm_runtime_get_sync to runtime resume it
first to enable clks, which matches the runtime suspend. (Only when
CONFIG_PM is defined, otherwise pm_runtime_get_sync will also be
empty, then runtime resume will not be called.)

Then it is fine to disable clks without causing clock count mis-match.

Fixes: c43eab3e

 ("net: fec: add missed clk_disable_unprepare in remove")
Signed-off-by: default avatarChuhong Yuan <>
Acked-by: default avatarFugang Duan <>
Signed-off-by: default avatarDavid S. Miller <>
Cc: Nobuhiro Iwamatsu <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 15d6d766
...@@ -3530,6 +3530,11 @@ fec_drv_remove(struct platform_device *pdev) ...@@ -3530,6 +3530,11 @@ fec_drv_remove(struct platform_device *pdev)
struct net_device *ndev = platform_get_drvdata(pdev); struct net_device *ndev = platform_get_drvdata(pdev);
struct fec_enet_private *fep = netdev_priv(ndev); struct fec_enet_private *fep = netdev_priv(ndev);
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
int ret;
ret = pm_runtime_get_sync(&pdev->dev);
if (ret < 0)
return ret;
cancel_work_sync(&fep->tx_timeout_work); cancel_work_sync(&fep->tx_timeout_work);
fec_ptp_stop(pdev); fec_ptp_stop(pdev);
...@@ -3537,15 +3542,17 @@ fec_drv_remove(struct platform_device *pdev) ...@@ -3537,15 +3542,17 @@ fec_drv_remove(struct platform_device *pdev)
fec_enet_mii_remove(fep); fec_enet_mii_remove(fep);
if (fep->reg_phy) if (fep->reg_phy)
regulator_disable(fep->reg_phy); regulator_disable(fep->reg_phy);
if (of_phy_is_fixed_link(np)) if (of_phy_is_fixed_link(np))
of_phy_deregister_fixed_link(np); of_phy_deregister_fixed_link(np);
of_node_put(fep->phy_node); of_node_put(fep->phy_node);
free_netdev(ndev); free_netdev(ndev);
return 0; return 0;
} }
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