drivers: net: cpsw: remove child devices while driver detach
authorMugunthan V N <mugunthanvnm@ti.com>
Mon, 13 Oct 2014 16:51:07 +0000 (22:21 +0530)
committerDavid S. Miller <davem@davemloft.net>
Tue, 14 Oct 2014 19:59:38 +0000 (15:59 -0400)
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>
drivers/net/ethernet/ti/cpsw.c

index ab167dc49ce4ca79579f7c0d953fa271f1e9acc9..952e1e4764b74d64688875815b25dc90316f3214 100644 (file)
@@ -2392,6 +2392,15 @@ clean_ndev_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)
 {
        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_ctlr_destroy(priv->dma);
        pm_runtime_disable(&pdev->dev);
+       device_for_each_child(&pdev->dev, NULL, cpsw_remove_child_device);
        if (priv->data.dual_emac)
                free_netdev(cpsw_get_slave_ndev(priv, 1));
        free_netdev(ndev);