net: ethernet: mediatek: fix issue of driver removal with interface is up
authorSean Wang <sean.wang@mediatek.com>
Thu, 1 Sep 2016 02:47:32 +0000 (10:47 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 1 Sep 2016 03:53:48 +0000 (20:53 -0700)
mtk_stop() must be called to stop for freeing DMA
resources acquired and restoring state changed by mtk_open()
firstly when module removal.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mediatek/mtk_eth_soc.c

index bf5b7e1d945083dbc51c72ae3324e92da7ea9245..556951e66978526da2647e6c9fbfd068ee090b72 100644 (file)
@@ -1906,6 +1906,14 @@ err_free_dev:
 static int mtk_remove(struct platform_device *pdev)
 {
        struct mtk_eth *eth = platform_get_drvdata(pdev);
+       int i;
+
+       /* stop all devices to make sure that dma is properly shut down */
+       for (i = 0; i < MTK_MAC_COUNT; i++) {
+               if (!eth->netdev[i])
+                       continue;
+               mtk_stop(eth->netdev[i]);
+       }
 
        clk_disable_unprepare(eth->clks[MTK_CLK_ETHIF]);
        clk_disable_unprepare(eth->clks[MTK_CLK_ESW]);