net: ethernet: ti: cpsw: use cpsw as drv data
authorIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Tue, 11 Jun 2019 21:49:03 +0000 (00:49 +0300)
committerDavid S. Miller <davem@davemloft.net>
Sat, 15 Jun 2019 01:43:48 +0000 (18:43 -0700)
No need to set ndev for drvdata when mainly cpsw reference is needed,
so correct this legacy decision.

Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ti/cpsw.c

index 6d3f1f3f90cb722f26115ba57d08aac09639c73c..3430503e105342f4284852919576edf3659c969e 100644 (file)
@@ -2265,8 +2265,7 @@ no_phy_slave:
 
 static void cpsw_remove_dt(struct platform_device *pdev)
 {
-       struct net_device *ndev = platform_get_drvdata(pdev);
-       struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
+       struct cpsw_common *cpsw = platform_get_drvdata(pdev);
        struct cpsw_platform_data *data = &cpsw->data;
        struct device_node *node = pdev->dev.of_node;
        struct device_node *slave_node;
@@ -2477,7 +2476,7 @@ static int cpsw_probe(struct platform_device *pdev)
                goto clean_cpts;
        }
 
-       platform_set_drvdata(pdev, ndev);
+       platform_set_drvdata(pdev, cpsw);
        priv = netdev_priv(ndev);
        priv->cpsw = cpsw;
        priv->ndev = ndev;
@@ -2570,9 +2569,8 @@ clean_runtime_disable_ret:
 
 static int cpsw_remove(struct platform_device *pdev)
 {
-       struct net_device *ndev = platform_get_drvdata(pdev);
-       struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
-       int ret;
+       struct cpsw_common *cpsw = platform_get_drvdata(pdev);
+       int i, ret;
 
        ret = pm_runtime_get_sync(&pdev->dev);
        if (ret < 0) {
@@ -2580,9 +2578,9 @@ static int cpsw_remove(struct platform_device *pdev)
                return ret;
        }
 
-       if (cpsw->data.dual_emac)
-               unregister_netdev(cpsw->slaves[1].ndev);
-       unregister_netdev(ndev);
+       for (i = 0; i < cpsw->data.slaves; i++)
+               if (cpsw->slaves[i].ndev)
+                       unregister_netdev(cpsw->slaves[i].ndev);
 
        cpts_release(cpsw->cpts);
        cpdma_ctlr_destroy(cpsw->dma);