2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-22 12:14:01 +08:00

drivers: net: cpsw: remove child devices while driver detach

remove all the child devices from the system to make sure that re-insert of
cpsw module doesn't fail on child device populated by of_platform_populate().

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Mugunthan V N 2014-10-13 22:21:07 +05:30 committed by David S. Miller
parent fc7a99fb71
commit 030b16a0e3

View File

@ -2392,6 +2392,15 @@ clean_ndev_ret:
return ret; return ret;
} }
static int cpsw_remove_child_device(struct device *dev, void *c)
{
struct platform_device *pdev = to_platform_device(dev);
of_device_unregister(pdev);
return 0;
}
static int cpsw_remove(struct platform_device *pdev) static int cpsw_remove(struct platform_device *pdev)
{ {
struct net_device *ndev = platform_get_drvdata(pdev); struct net_device *ndev = platform_get_drvdata(pdev);
@ -2406,6 +2415,7 @@ static int cpsw_remove(struct platform_device *pdev)
cpdma_chan_destroy(priv->rxch); cpdma_chan_destroy(priv->rxch);
cpdma_ctlr_destroy(priv->dma); cpdma_ctlr_destroy(priv->dma);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
device_for_each_child(&pdev->dev, NULL, cpsw_remove_child_device);
if (priv->data.dual_emac) if (priv->data.dual_emac)
free_netdev(cpsw_get_slave_ndev(priv, 1)); free_netdev(cpsw_get_slave_ndev(priv, 1));
free_netdev(ndev); free_netdev(ndev);